-
Notifications
You must be signed in to change notification settings - Fork 932
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
Should we invoke onStateChange with _all_ the state? #123
Comments
I would prefer that, myself. I noticed in the function that you passed most of what I'd be looking for, but why not show it all? Someone therefore can fire a side effect of any mutation they need at this point, and you're allowing folks to access the plumbing more easily. Ultimately the big picture for this project seems to be that it is an api that enables folks to build any ui, so exposing more is not out of touch with the design direction of the component. |
Cool! I've almost got that done. Thanks for the validation. Also, I'm improving things slightly. So now your |
Also adds a second parameter that has all the state Closes #123
Ok I'll update my examples with this in mind, I plan on adding more features to it when this version is published also. |
It's published as the latest |
downshift
version:1.0.0-rc.3
Relevant code or config
Reproduction:
https://codesandbox.io/s/5yJ3G59jA
Problem description:
In my
handleStateChange
handler, I have to check whetherinputValue
is included in the changes if I want to set the state.Suggested solution:
What if we just always pass all the state to your
onStateChange
callback? Then you wouldn't have to check whetherinputValue
(and other state) exists in the changes.As I was creating this, I was thinking that maybe we should leave it as it is, because the alternative wouldn't enable you to know what changed, just that something changed.
But what if we did both? So it'd be:
this.props.onStateChange(changes, allState)
? I think that'd be a good compromise, so I'm going to do that 😄The text was updated successfully, but these errors were encountered: