Skip to content

Set useForm context when invoking handleSubmit #10672

Answered by leapful
Edelf asked this question in Q&A
Discussion options

You must be logged in to vote

@Edelf

You don't need to use local state for context, it only the conditional schema on next re-rendering, not on submit. Just use a simple ref from useRef hook is enough.

Working demo: https://codesandbox.io/s/resolver-context-forked-qsmzpc?file=/src/App.tsx

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Edelf
Comment options

@leapful
Comment options

leapful Jul 14, 2023
Collaborator

Answer selected by Edelf
@Edelf
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants