A minimal Universal React redux JS stack using Flow, with hot reloading, linting and server-side rendering.
This is a universal react project. It provides server-side rendering and uses Flow syntax. We put together React Redux Saucepan here at elsewhen, and included the things you most likely need and take out the things you may not want. We also do our best to keep this maintained and updated. Posting any issues, questions, suggestions and PRs are more than welcome :).
First make sure you have at least node 8, and we recommend using npm 6
git clone https://github.com/elsewhencode/react-redux-saucepan
react-redux-saucepan
cd react-redux-saucepan
npm i
npm run start:dev
Open http://localhost:3000 to view it in the browser.
npm start
dist
folder):npm run build
npm run start:dev
npm run flow
npm run lint
npm test
.
├── dist
|
├── docs
|
├── flow-typed
|
├── scripts
| ├── webpack.client.js
| ├── webpack.dev.js
| └── webpack.server.js
|
├── src
| ├── client
| | └── ...
| |
| ├── server
| | └── ...
| |
| ├── shared
| | ├── api
| | | └── ...
| | |
| | ├── components
| | | └── ...
| | |
| | └── pages
| | └── ...
| |
| └── util
|
└── static
client
,server
and shared
folders?Work in progress...
Work in progress...
When running in development mode, there will be an express file: ./src/server/index.dev.js
that serves you. It will consume your dev webpack config in ./scripts/webpack.dev.js
using webpack-dev-middleware. It will throw an empty html file (./src/server/html.js
) which initiates the react app on browser (there is no server-side rendering in dev mode). This is the same html file that gets used in production, so you an have the same meta, favicon etc.. . Instead of using node to run index.dev.js
we use babel-watch. This enables you to use latest JS syntax on the server and watch for any changes and reload it if necessary.
There is hot reloading available to make development easier for you. Eslint, flow and stylelint are also checked on the fly as you add new code to the project. ./scripts/webpack.dev.js
sets the global __DEVELOPMENT__
to true
which you can use in your code.
To run the app in development mode, simply run:You can build the app by running:
npm run build
Build is done by webpack for both server-side and client-side. The output is set to ./dist
folder which is Webpack's default output directory. The process includes Flow type checking, linting, and transpiling for both client and server. You can find webpack configs in ./scripts
folder.
Transpiling is set in .browserslistrc
using browserslist for your target browsers and done by babel-env.
There are global variables set to help you check whether you're on client or server in the runtime: __CLIENT__
and __SERVER__
. Also both client and server webpack configs will set __PRODUCTION__
global to true
and __DEVELOPMENT__
to false
.
You can build the app by running:
npm run build
the you can run the app by running:
node dist/index.js
build
script is also set as a prestart for starting the app in production mode. So you can run above steps at once:
npm start
Values that can set by developer are PORT
, and HOST
that can be set in a .env
file which is read by ./config.js
and then used across the app.
We havn't written any test yet and it's in our todo list is in our to do list.
npm test
We try to follow our Javascript project guidelines as much as we can, but we also like to keep this app quite minimal. You will find most of the Elsewhen's project guidelines in the tools we use and the way folders are structures, as well as naming, linting and chosen dependencies.
This project uses Airbnb's javascript style guide for Javascript syntax and flowtype/recommended
for Flow syntax using eslint-plugin-flowtype
.
For styles we use stylelint-config-standard which is checked by Stylelint. This checks your style-components code using stylelint-processor-styled-components.
You can check your code style by simply running:
npm run lint
React Redux Saucepan uses Github rest api to represent some sample data. You can find the requests done by axios in ./src/shared/api/index.js
. Api calls are made in both client and server side (to include the data in server-side rendered markup).
React Redux Saucepan is open source software licensed as MIT.
目录 为何组件没有被重新渲染、或者 mapStateToProps 没有运行? 为何组件频繁的重新渲染? 怎样使 mapStateToProps 执行更快? 为何不在被连接的组件中使用 this.props.dispatch ? 应该只连接到顶层组件吗,或者可以在组件树中连接到不同组件吗? React Redux 为何组件没有被重新渲染、或者 mapStateToProps 没有运行? 目前来看,
Universal React Redux Boilerplate A universal React/Redux boilerplate with sensible defaults. Out of the box, thisboilerplate comes with: Server-side rendering with Express Code splitting with dynamic
React-Redux-Enterprise A React-Redux boilerplate for enterprise web applications. Before you start with this boilerplate, please take a few minutes to read this article and see if you really need this
Live redux-react-starter This repository contains the minimal app to get started with redux, react, hot-reloading, async function and some other great stuffs. How to yarn 0.18+ must be present on your
React/Redux Links Curated tutorial and resource links I've collected on React, Redux, ES6, and more, meant to be a collection of high-quality articles and resources for someone who wants to learn abou
React-Redux-Flask Boilerplate application for a Flask JWT Backend and a React/Redux Front-End with Material UI. Python 2.7+ or 3.x Pytest Heroku Flask React Redux React-Router 2.0 React-Router-Redux B