This is a project to showcase Next with Redux and Sagas making API calls and having those calls integrated in a full sagas data flow.
It's about blocking vs non-blocking.
A page can trigger execution of a saga with an action from its getInitialProps method like so:
class Home extends Component {
static async getInitialProps({ store }) {
store.dispatch(pokemonIndexRequested());
}
render() {
...
}
}
Must be an async function
The server will wait for execution of the saga and all related sagas and actions before it renders the page with one condition: sagas effect must be blocking or at least attached.
In some cases this can mean substituting spawn
(detached effect) for fork
(attached effect).
- yarn
- yarn dev
- visit project at localhost:3000