-
Notifications
You must be signed in to change notification settings - Fork 1.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
Reset form-like components when the parent <form>
resets
#2004
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This splitsup the raw `[state, dispatch]` to separate `useActions` and `useData` hooks. This allows us to make the actions themselves simpler and include logic that doesn't really belong in the reducer itself. This also allows us to expose data via the `useData` hook that doesn't belong in the state exposed from the `useReducer` hook. E.g.: we used to store a `propsRef` from the root `Listbox`, and update the ref with the new props in a `useEffect`. Now, we will just expose that information directly via the `useData` hook. This simplifies the code, removes useEffect's and so on.
If the `isControlled` value changes, then the references to all the functions changed. Now they won't because of the `useEvent` hooks.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
RobinMalfait
force-pushed
the
fix/issue-1950
branch
from
November 9, 2022 22:36
fed3910
to
2005f1a
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes an issue where the form-like components (
Listbox
,Switch
,RadioGroup
andCombobox
) didn't reset its value to thedefaultValue
when the parent<form>
received areset
event.This PR also includes some refactoring for those components so that the change itself was a bit easier to apply.
Fixes: #1950