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
How to implement Redux? #600
Comments
Here's a basic example, a reimplementation of the Redux counter app in react-server: All you need is redux and react-redux. Setting it up is similar to plain Redux. Now how you structure a react-server, Redux application is up to you. |
Whoa! @hzhu that's awesome! We should link to that example from our docs. Leaving this open as a reminder. |
Yeah I was planning on that! How about I submit a PR for review in a day or two? |
Even better! Thanks @hzhu! |
@hzhu thanks a lot!! |
@incubus8 I realized that the Counter example isn't too useful once one introduces data fetching & user interaction. Here's a better use case with react-server & redux. It's still a work in progress, but seems to work. https://github.com/hzhu/react-server-redux It's a bit messy, but once I learn how to cleanly setup a redux project with react-server, I'll make the PR to react-server-examples |
@hzhu Any chance you've had any luck using the RootElement's 'when' with Redux? I'd like to render a component only when an async data call has completed, but 'where' requires a Promise, and my dispatch will no longer work if I return a promise instead of a function. |
@woomike, did you mean RootElement's You can try representing your async data fetching as a promise, and put that, as the value to
Or more likely you might want to use I have a working demo of rendering async data using redux and react-server. The specific line you might want to check out is https://github.com/hzhu/react-server-redux/blob/master/src/pages/explore/index.js#L35 Note: I'm finding it very difficult to structure a redux app properly in react-server, i.e. how to manage store/stores & reducers. Let me know if you have some tips :) |
@hzhu Thanks so much for getting back to me. My apologies on the typo, yes I meant
|
Hi guys, any idea how to implement Redux? where can I find example Redux + React Server?
The text was updated successfully, but these errors were encountered: