-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
feat: Added ability to provide patching function to setStatus method #3931
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit ede3399:
|
@quantizor @johnrom @jaredpalmer just wanted to ask you for PR review explicitly |
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.
Can you add a patch changeset please?
I'm not sure what the purpose of this change is. Are you creating a new status based on the last status? It's not really clear by default where this status comes from (render or state), so I would expect Formik (if it is being brought back from the dead) to move in a direction where the source of this value can be determined explicitly, either within a render using const { setStatus, getState, status } = useFormikContext();
useEffect(() => { setStatus(status === "value in current render" ? "a" : "b"); }, [setStatus, status]);
useEffect(() => { setStatus(getState().status === "absolutely current value" ? "a" : "b"); }, [setStatus, getState]); You can see what that API could look like here: #3231 (the file doesn't load initially, so check |
Problem
When setting status, sometimes user needs to update the existing value. When used inside a useCallback hook for instance, it introduces an unnecessary variable to the dependency list.
Solution
setStatus now acepts a patching function