-
We have the scenario where the user has the option to save the form, or submit it. Looking at the documentation, the useForm Context seemed interesting, but would require some sort of synchronous sequence where when the user clicks on save, we first change the context, and then call the handleSubmit. If the handleSubmit accepted a new context, it would be great, e.g. Is there a way to achieve this sort of behavior currently? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Option Example: https://codesandbox.io/s/resolver-context-d9jqy |
Beta Was this translation helpful? Give feedback.
@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