Skip to content

How to dispatch action client side only? #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
AndrewRayCode opened this issue Feb 29, 2016 · 3 comments
Open

How to dispatch action client side only? #56

AndrewRayCode opened this issue Feb 29, 2016 · 3 comments

Comments

@AndrewRayCode
Copy link

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 erikras/react-redux-universal-hot-example#971

@andresgutgon
Copy link

Similar issue here: #55

I think it's not clear how to declare deferred request with redux-async-connect. What are we missing?

@kjanoudi
Copy link

kjanoudi commented Mar 2, 2016

+1

@babsonmatt
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants