Giter Club home page Giter Club logo

react-ssr-starter's Introduction

react-ssr-starter

All have been introduced React environment.

Features

Install

$ git clone https://github.com/osamu38/react-ssr-starter.git
$ cd react-ssr-starter
$ npm i

Run

$ npm run dev

Go to http://localhost:2525/.

Build

$ npm run build
$ npm run build:client (Only build client)
$ npm run build:server (Only build server)

Build and analyze

$ npm run build:analyze
$ npm run build:client:analyze
$ npm run build:server:analyze

Run for production

npm start

Go to http://localhost:2525/.

Adding pages

Basically page component is implemented using Functional Component.

pages/home/index.js

import React from 'react';
import { Helmet } from 'react-helmet-async';
import Title from 'components/Title';
import SubTitle from 'components/SubTitle';
import UserList from 'components/UserList';
import { fetchUsers } from 'actions/user';

const HomePage = (props) => {
  const {
    state: {
      user: { userList },
    },
  } = props;

  return (
    <>
      <Helmet title="Home" />
      <Title>Home Page</Title>
      <SubTitle>User List</SubTitle>
      <UserList userList={userList} />
    </>
  );
};

HomePage.loadData = async (ctx) => {
  const {
    dispatch,
    state: {
      user: { userList },
    },
  } = ctx;

  if (!userList.length) {
    return dispatch(fetchUsers());
  }
  return Promise.resolve();
};

export default HomePage;

react-ssr-starter's People

Contributors

osamu38 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-ssr-starter's Issues

TypeError: Cannot read property 'match' of undefined

Hii, i try using your boilerplate.. so far build with this boilerplate is okay, but sometimes i got error like this..

TypeError: Cannot read property 'match' of undefined at Function.match [as loadData] (/Users/mac/Documents/Workspace_Air/###polosan.bandung.v.4.0/src/pages/ProductDetail/index.js:16:59) at loadData (/Users/mac/Documents/Workspace_Air/###polosan.bandung.v.4.0/src/server.js:58:23) at Array.map (<anonymous>) at map (/Users/mac/Documents/Workspace_Air/###polosan.bandung.v.4.0/src/server.js:57:6) at getLoadBranchData (/Users/mac/Documents/Workspace_Air/###polosan.bandung.v.4.0/src/server.js:157:26) at tryCatch (/Users/mac/Documents/Workspace_Air/###polosan.bandung.v.4.0/node_modules/regenerator-runtime/runtime.js:45:40) at Generator.invoke [as _invoke] (/Users/mac/Documents/Workspace_Air/###polosan.bandung.v.4.0/node_modules/regenerator-runtime/runtime.js:271:22) at Generator.prototype.<computed> [as next] (/Users/mac/Documents/Workspace_Air/###polosan.bandung.v.4.0/node_modules/regenerator-runtime/runtime.js:97:21) at asyncGeneratorStep (/Users/mac/Documents/Workspace_Air/###polosan.bandung.v.4.0/src/server.js:66:103) at _next (/Users/mac/Documents/Workspace_Air/###polosan.bandung.v.4.0/src/server.js:68:194)

when trying to get 'http://localhost:2525/product-detail/8' <!-- which is when first load i have no problem, but when i try to load page.. i've got an error like above..

Change rendering type to CSR

Hello, I have a question.
I need to change rendering from SSR to CSR with the index.html file in the dist folder. Can I make it with this starter kit?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.