-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Description
Does Redial supports multiple trigger when many components is displayed on the same page? It's on an universal implementation
For example:
article.js
@provideHook({
fetch: //...
})
class ArticlePage extends React.Component {
//...
render() {
return (
<article>
...
<List/>
</article>
)
}
}list.js
@provideHook({
fetch: //...
})
class List extends React.Component {
//...
render() {
return (
<ul>
...
</ul>
)
}
}client.js
const { components } = renderProps;
const { dispatch } = store;
const locals = {
path: renderProps.location.pathname,
query: renderProps.location.query,
params: renderProps.params,
dispatch
};
if (window.__INITIAL_STATE__) {
delete window.__INITIAL_STATE__;
} else {
trigger('fetch', components, locals);
}
trigger('defer', components, locals);server.js
const locals = {
path: renderProps.location.pathname,
query: renderProps.location.query,
params: renderProps.params,
dispatch
};
trigger('fetch', components, locals)
.then(() => {
const html = template({
root: renderToStaticMarkup(
<Provider store={store}>
<RouterContext {...renderProps} />
</Provider>
),
initialState: getState(),
jsBundle: clientAssets.main.js,
cssBundle: clientAssets.main.css,
});
response.status(200).send(`<!doctype html>${html}`);
}, () => {
response.status(503).send('Fail on fetching data');
})
.catch(() => {
response.status(500).send('Fail on fetching data');
});Thanks for your help!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels