On server, we use renderProps from react-router match callback. We iterate
over components, looking after components decorated with asyncData
On client we use AsyncHandler component in react-router render, where we
bind to componentWillMount to check data after startup and then componentWillReceiveProps
to check for route changing
We don't do any optimisations, as we can do that on connected component, which receive
in decorated function all it needs, like location, params, dispatch, getState
res.status(404);// page not found in router, you should try to hydrate app on client
hydrateOnClient();
}
})
Component decorator
For decorating component you can use default export. Decorator must contain function, which return promise.
If you have more than one promises, wrap them in Promise.all
importasyncDatafrom'react-simple-async';
@asyncData(function({getState, dispatch}){//available params, location and all keys defined in custom prop of AsyncHandler
let promises =[];
if(isSomethingFetched(getState())){//check if you really need fetch