Conversation
CHANGELOG.md
Outdated
|
|
||
| You can now pass an optional selector function to `connect`. It will be | ||
| passed the `state` and should return an object which will be merged with | ||
| the component's `props` using `Object.assign({}, props, substate`. |
Thanks. I'll add an example and tests for |
|
|
||
| You can now pass an optional selector function to `connect`. It will be | ||
| passed the `state` and should return an object which will be merged with | ||
| the component's `props` using `Object.assign({}, props, substate)`. |
There was a problem hiding this comment.
The order of first props then substate mimics what Redux does. I've wondered why they implement it this way. substate, props would allow overriding the props from state which sounds like it could be useful sometimes.
There was a problem hiding this comment.
I definitely think this makes more sense but I am curious as to what trade off the redux team made when they designed it the other way. There has to be a reason behind it.
Once this is fixed 👍 |
| render(); | ||
| }, | ||
| connect(component) { | ||
| connect(component, selector = state => state) { |
There was a problem hiding this comment.
just a nit / question -- is your preference to keep the selector as the second arg, vs the react-redux style
const ConnectedFoo = connect(state => ({ bar: state.foo.bar }))(Foo);There was a problem hiding this comment.
I guess (to kinda answer my own question) your way allows connecting to the state without any selectors.
There was a problem hiding this comment.
which would need to be something like the following in react-redux style,
const ConnectedFoo = connect()(Foo);
Here's a WIP of my proposal to fix #19. I still need to add more tests and fix the failing ones. In the interest of gathering feedback early I'm submitting the PR now.
I split the change into three commits and it might be helpful to review them one by one.