1.0.0 • Published 7 years ago
sync-will-mount v1.0.0
sync-will-mount
Middleware for express that is making componentWillMount synchronize on server render
More developers find the way for react server render; So I've written a module to override react-dom for server render. No component static method, no decorators, and no any hook on module export. Just put actions on componentWillMount if some data you wait to render form server for seo. the lifecycle will wait for promise, like this:
->componentWillMount ->redux middleware ->sync request ->next to other middleware ->reducers ->render
Try it, and if it has something problem, please let me know or create issue to me.
THX
Install
$ npm install sync-will-mount --save
Usage for your entry file
// require when your store initial on server
const syncWillMount = require("sync-will-mount")
const initAsyncBeApi = syncWillMount(remoteDataUrl);
middlewares = [initAsyncBeApi(req)].concat(middlewares || []);
Component you want to render with data
// componentWillMount
componentWillMount() {
action1();
action2(()=>{
action3();
});
}