redux-async-connect
redux-async-connect copied to clipboard
How to dispatch action client side only?
My use case: I need some actions to dispatch only on the client side. This includes on first page load. Right now I have something like:
@asyncConnect([{
promise: ({ store: { dispatch, getState } }) => {
if( !__SERVER__ ) {
return dispatch( clientOnly() );
}
}
}]);
However this doesn't execute on the client side on first page load. It only executes if I navigate to the page at a later time.
See also https://github.com/erikras/react-redux-universal-hot-example/issues/971
Similar issue here: https://github.com/Rezonans/redux-async-connect/issues/55
I think it's not clear how to declare deferred
request with redux-async-connect
. What are we missing?
+1
I was stuck with doing this as well, you can pass a filter prop to ReduxAsyncConnect. You can do something like:
ReactDOM.render(
<Provider store={store}>
<Router render={(props) => <ReduxAsyncConnect {...props} filter={item => !item.deferred} />} history={history}>
{routes}
</Router>
</Provider>,
dest
);
or whatever you'd like.
Discovered this after being referred to: https://github.com/erikras/react-redux-universal-hot-example/blob/615dfcd2562b8380e1d199b3d840d292358198dc/src/client.js#L39