useAsyncDefaultValues for when you need to wait for a prop #9979
Unanswered
hornta
asked this question in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I made a handy little hook that can be used to create default values by for example waiting for a prop. In our case we fetched the object to be populated in the form outside the component.
The hook can be changed to make it a bit less noisy so it could like this:
defaultValues: useAsyncDefaultValues(()=>{ ... }, [...])
.Also you can add this to the eslint config to get the same useEffect dependency rule for the hook.
Beta Was this translation helpful? Give feedback.
All reactions