-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
Document Redux setup in additional environments like React Native and Next.js and link additional templates #4035
Comments
Just FYI, I should have a JS version of the RN template as well as TS and JS versions for Expo coming soon. Will look into adding these to the docs in a way that doesn't look ridiculous. |
I've worked a bit on the RN docs side of things. I think a PR is ready for that one. I wanted to wait until I added the NextJS section but had some questions on it first. You mentioned that we probably want to document usage of NextJS's data fetching APIs, but the template linked doesn't seem to use AFAIK, even prior NextJS projects I've worked in before have tended not to utilize these methods in prod |
Yeah, that's something that had crossed my mind. Part of me says that not everyone is going to need to do SSR-type behavior and need But, it's also a common enough thing that I can see the point in having the official Redux+Next starter project have that built in to at least show how it should be set up.\ I know that the Next folks are happy to accept PRs to improve those projects, I just don't have time to even think about that work myself. |
You know, I honestly just didn't even know about It even has a NextJS repo example: https://github.com/vercel/next.js/tree/canary/examples/with-redux-wrapper If we're okay with using the |
Sounds good! It may be worth at least mentioning that RTK 1.7 will have SSR support as well. |
I wrote a Reddit comment recently about how Next and Redux fit together: Pasting here for ease of reading:
|
I just wrote up a fairly similar comment and am pasting here for posterity and later documenting:
|
Hiya! I can take care to add a good RN example but with Expo. Expo is recommended for beginners/mid-levels based on RN docs and it has a lot of advantages. 👉 This could be motivating to new redux learners + existing developers (like me 😃) . Also, I know experts in the React Native community who hadn't used Expo before, but today they changed their minds after hearing about Expo team's updates over the past 2 years, especially since the appearance of EAS services Note: for more information about new Expo's features in recent years visit this link. 👉 I don't know about Next.js and will not be able to do anything on it. Would you agree with me on working only on adding RN (example + docs) to redux website? 🙏 Just give me the go 💚 thanks |
@fregayeg honestly though, as redux is a non-native library there shouldn't be any discernible difference between setting it up with vanilla RN or expo, right? |
I think yes! We can consider redux in both RN & Expo as third-party acceptable dependency. Maybe the only difference is: When using Expo Go app, debugging with redux devtools could not work properly. But DW I have experienced such case and today I know how to solve this in few simple ways 😉( it'll be obvious to add these information). So do you agree ? |
@fregayeg : FWIW, the request in this page isn't actually for a full-blown app :) What I'm looking for is something sort of along the lines of the existing "Configuring Your Store" page, that would answer questions like:
|
Ok but there is some other interesting topics such:
👉 Some components are only in mobile, and may need a useful state management system such Redux. One of these component is called bottom-sheet. |
Hmm. @fregayeg , I definitely want any differences in Redux DevTools setup covered (if there are any), but I don't think we need to worry about navigation or testing. |
My 2 cents regarding Next.js. First my current understanding is that Redux is already SSR friendly, which explains why the Next.js official redux example is pretty straightforward. In previous versions, you could use In Next.js 13, each React Server Components is able to call some server code, and you can now do things at page-level. This means you have to handle a tree structure instead of top-level pages. Therefore, you might need a way to instanciate the store once and carry it around. But you don't have usual React context in RSC. (disclaimer: I don't use Redux and haven't in a while so take all this with a pinch of salt) |
@eric-burel The Nextjs official redux example that you link there unfortunately does not work for SSR. If you want to use Redux with SSR on Next, you need additional logic that rehydrates the SSR state on the client, and makes sure that each SSR run has a separate Redux store. WIth that official example, all SSR pages would share one store between all users. We will probably wait what https://github.com/kirill-konshin/next-redux-wrapper brings to the table for Next 13, since it is already impossible to use Redux + Next SSR without that. |
Some related |
WE'VE FINALLY GOT DOCS FOR SETUP WITH NEXT!!!! |
Our docs currently teach app setup based on a standard SPA-style approach, and specifically with use of Create-React-App. Related, our installation instructions currently point to the two RTK templates for CRA (JS and TS).
We should add additional installation and setup instructions for other major React environments, like React Native and Next which both differ significantly in how the app structure is defined and have different considerations (no
ReactDOM.render()
call in RN or Next, and Next users will likely want to integrate with Next's data fetching APIs).We could possibly do this by updating/rewriting https://redux.js.org/usage/configuring-your-store to be more about "how do you set up a Redux store in various environments?" and covering RN/Next specifically as part of that, or we could keep the idea of "store configuration" and "app project setup" in separate pages.
Related to this, it would be nice if we could point to specific templates for those environments as well.
For RN, there's https://github.com/rahsheen/react-native-template-redux-typescript , which ports the RTK+TS example to the RN CLI.
For Next, there's https://github.com/vercel/next.js/tree/canary/examples/with-redux , which does something similar.
The text was updated successfully, but these errors were encountered: