-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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
Suggestion for with-redux example: using higher-order component to replace repeated codes. #1193
Comments
And considering this kind of higer-order component might be commonly used in every next.js project, I wonder if it's a good idea to make it a next.js third-part library? |
I think @borellvi and @arunoda try to keep it same as |
@katopz It just changed the code structure of the original version of |
@huzidaha I know it's easy and made sense and it's a way to go for real life using but in case you introduce another dependency And also FYI : #1196 |
I actually want to make a PR. But I am wondering if it's polite to replace his example... |
I create a PR #1201 which uses the package next-connect-redux I am working on and it's base on the idea above. See https://github.com/huzidaha/next-connect-redux/blob/master/lib/index.js. I will finish the docs and tests of next-connect-redux as soon as possible. |
@huzidaha it's pure coincidence, I haven't seen this issue before today, I was working on my stuff for last couple of days, and as you see, I use slightly different approach. kirill-konshin/react-ssr-playground@0ebca3d here is the link to my playground, dated Feb 16. https://github.com/huzidaha/next-connect-redux/blob/master/lib/index.js#L15 you have a bug on this line because redux will ignore default state coming from reducer, default state has to be undefined. Also where is the store memoization, so that on a client there will be just one instance? Have you tested it? https://github.com/huzidaha/next-connect-redux/blob/master/lib/index.js#L42 connect has 3rd argument I suggest to leave the example as is. @huzidaha I can add you as collaborator to my project, if you want. |
@kirill-konshin I am really sorry for the misunderstanding. And thank you for the suggestions. :P |
Use the original idea of provider wrapper from #1193 and remove unnecessary `initStore` in every page.
@kirill-konshin the PR description referencing the issue made me think his implementation predated yours. I will revert. |
Also, maybe to have the best of both worlds, @kuzihada, you can PR later a little note on the README saying that there's another package available and link to yours ? |
@kirill-konshin apologize for the confusion |
No worries. |
@rauchg I really appreciate for that. |
The example of next.js with redux has repeated codes in every page, but wouldn't it be better to use higher-order component to replace this kind of repeated codes. For example:
next-connect.js:
In every page you can easily use next-connect.js and connect to store like using redux normally:
index.js:
You can gain the same abilities like
with-redux
example does but with convenience.Just a suggestion, feel free to close.
The text was updated successfully, but these errors were encountered: