-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
Using combineReducers
to define shape of the state
#1591
Conversation
29c8cf8
to
e9518ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really good, I find this to be much cleaner and easier to read. Tested it locally and it works as per normal and without error 👍
Should the routeReducer
also be updated for consistency (example below)?
function locationBeforeTransitions(state = null, action) {
switch (action.type) {
/* istanbul ignore next */
case LOCATION_CHANGE:
return action.payload;
default:
return state;
}
}
const routeReducer = combineReducers({ locationBeforeTransitions });
@samit4me good point! I've updated the code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ✨
Looks like AppVeyor and Chrome strikes again.
@gihrig @KarandikarMihir Are you able to cast your eyes over this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generators need updating - see testing comment.
A generated route shows the Not Found Page in production mode, OK in dev mode. I tested according to the following script.
|
Yes but, It's a break from the "standard" redux reducer pattern most people are familiar with. To expect that a new immutable state object will be returned when the reducer returns a boolean, just make no "sense" (there must be some "magic" happening somewhere). I'm not arguing against this PR, but another, similar proposal was made to use redux-actions to greatly simplify the creation of actions in #1476 and that idea was shot down for this reason. If we are to go forward with the change, I would suggest:
Overall I like the change, boilerplate reduction is (usually) a good thing. 😄 |
@gihrig thanks for your input. I've updated the templates.
That's weird - the changes in this PR don't introduce anything that might cause that. The reducers should work exactly the same as previously. I've just tested your scenario and I can't reproduce it.
I'm not sure about that. Combining reducers is mentioned in the redux docs and it's a quite standard thing IMO.
I'm afraid I will not find time to address your suggestions. I've been quite busy with other stuff and it becomes more difficult for to keep the #92 branch alive (that's the main reason for this PR). If you guys are not happy with this PR then we can close it and I'd remove these changes from #92 (they are not actually critical for it) to keep it leaner. |
#92 Yikes, I had no idea this project (SSR) went back that far. It's been a long haul!
@tomazy It was absolutely not my intention to discourage. But I am concerned about the approachability of the project. It's got plenty of difficult stuff as is.
I totally agree about combining reducers, no issue there. It's the change from returning an obvious state object to returning a primitive value. e.g. changing from: // Delete prefixed '@' from the github username
return state
.set('username', action.name.replace(/@/gi, '')); to: // Delete prefixed '@' from the github username
return action.name.replace(/@/gi, ''); It looks to me like a simple string is being returned rather than an immutable state object. Obviously I don't grok what's really happening here, that's all.
I totally get it about difficulty finding time! 😬 What do you, and others think about creating an SSR branch in this project? Kept up as a super-set of dev, that would allow these related PRs to have a place to live as an evolving sub-project. This PR for example would be right at home in a branch dedicated to SSR and the issues I raised could be addressed separately by the community. I'm hopeful that would invite wider contribution to the SSR feature and still facilitate release as a part, or all?, of RBP 4.0. With huge props to @tomazy for all the work put in on this long journey, I'd like to hear input from others. I think SSR is too big a feature to let slip away. |
I'm sure about that.
I understand it's hard to find balance between the approachability vs. best practices. I know it's all subjective but I'd put more emphasis on the latter.
Sounds good to me |
Cloned a new copy of your branch tested as before, all pass ✨ So this PR has my approval, but I'll let others have a say as to whether to merge into dev or create an SSR branch. |
@tomazy ping! |
@blling here you go |
Nice work |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This is another PR extracted from #1236
Please help me to review it.