Your project is preconfigured with a Redux store, available both at the server and the client.
The store has a combineReducers as the root reducer, and you can add your reducers to it by exporting an object from src/store/reducers.js
.
In addittion to your reducers, there are a few already preconfigured:
intl
: Your locale settings, managed by react-intl-reduxuseFetch
: The request cache for ruse-fetchreq
: (server only) Info about the request being rendered, such as the source ip or headersYou can override them by creating a key with the same name, but things can fail if you break their contract.
If you need to add any extra Redux middlewares to the store, you can create src/store/middlewares.js
and export an array of middlewares to configure them. The thunk middleware will be added automatically.
There are some actions that get dispatched during various stages of the render process, which can be used on your reducers:
REQUEST_INIT
: Dispatched before starting rendering. Contains info about the request being rendered.CLEANUP
: Dispatched after render, but before serializing the store. Allows cleaning up any info that should not be serialized and sent to the client.CLIENT_INIT
: Dispatched after store init, but before render. Allows middlewares to update the store before the first client render.You can import their action types like this:
import { CLEANUP } from 'universal-scripts'
Now that you know how the store works, you can learn more about the build system.