-
-
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
Change composeStores to throw if undefined is returned #191
Comments
To be honest I can't imagine
|
Here's something wrong with this change. People will start with Therefore I propose, instead of interpreting It's a breaking change, but one that is easy to fix with |
I have a stores with |
Do you really check for undefined or just !token ? Also, instead or just returning a single value you could wrap it in an object and keep your undefined value. I would welcome this change. It is a bit more opinionated, but it will solve some common mistakes. Sent from my iPhone
|
I don't want to wrap every single value with an object. I want to write Yes, I'm just checking for positive value |
I welcome this change (in the latter edition), no @vslinko I think enforcing |
I think |
I'm not really sure about this. First of all, it's up to userland to correctly implement a But if we do want to check that on our (redux) side, then I would suggest to just log a warning like React does. We also have a proposal for that about mutable state #138 |
@vslinko If it's really a valid use case for you and a matter of principle, you can always use your own |
If we just log a warning we get the worst of both options in my opinion. People having the problem might fail toah notice it (because they'll be focused on the actual error which is likely to happen in the component), but people like @vslinko who actually want undefined to be a valid value will be annoyed because of the pointless warning when they know what they're doing. Redux tries to be in opinionated and not include "shortcuts" if possible because community can build them just fine. I think that when we do include a shortcut like |
This is also my stance. Just forbidding null sounds like an unnecessary strict policy. |
Error is definitely better than warning. |
@gaearon would it make sense to make this shortcuts somehow removable from the total library footprint, so that experienced users won't need to have these unused shortcuts take bundle size? Say, importing |
At the end, it's hard to make everyone happy :) I'm also fine with throwing, was just trying to find a "soft" solution. I guess we just have to try and see how it goes... |
We'll probably ask people to export stuff like this from |
Also, with React 0.14 we'll probably be able to kill Then we can put all “non-core” stuff into import { createRedux } from 'redux';
import { Connector, Provider, composeReducers } from 'redux/addons';
// can also import individually:
import Connector from 'redux/addons/Connector'; |
👍 |
awesome 👍 |
Is anyone working on this? I can work on this change |
This is done now via #197. |
Right now it's easy to forget a
default
case and have your reducer return nothing in some circumstances. There have been some WIP attempts to address it: #174. Here's the issue that spawned that PR: #173.But let's take a moment to think about what
composeStores
really is. It's a shortcut right? It's a bit opinionated already: it assumes plain objects as the initial state. See #153.Can we make it a bit more opinionated for convenience?
We could make it return the previousstate
if the reducer returnsundefined
.Edit: see this instead.
Pros:
Cons:
Thoughts?
The text was updated successfully, but these errors were encountered: