Skip to content
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

"isLoading" form state for async default values #9525

Closed
psteinroe opened this issue Dec 5, 2022 · 1 comment
Closed

"isLoading" form state for async default values #9525

psteinroe opened this issue Dec 5, 2022 · 1 comment
Labels
feature request request a feature to be added waiting-up-vote Waiting for votes from the community.

Comments

@psteinroe
Copy link

Is your feature request related to a problem? Please describe.
I have been playing around with the new async default values discussed in #9046 and really love the dx. However, there is one thing missing for me: A formState to know whether the default values have been initialised, e.g. isLoading or isInitialised.

Describe the solution you'd like
Add a value to formState that indicates whether the default values have been loaded.

Describe alternatives you've considered

  • Watching a value in the form
  • Set an external state from within the defaultValues callback

Additional context
Thanks for all the great work! I hope this is the right place for this request.

@psteinroe psteinroe added feature request request a feature to be added waiting-up-vote Waiting for votes from the community. labels Dec 5, 2022
@bluebill1049
Copy link
Member

bluebill1049 commented Dec 5, 2022

yea, we can consider adding that for sure. I will put this into the backlog for now and move it to the RFC column. 👍

const { formState: { isLoading } } = useForm()

I think isLoading is pretty good and libraries such as SWR, use that term as well. Probably cut this in next year's release.

@bluebill1049 bluebill1049 added this to API proposal / RFC in React Hook Form Dec 5, 2022
bluebill1049 added a commit that referenced this issue Dec 14, 2022
* close #9525 add isLoading state for async defaultValues

* update unit test for isLoading state and set default to true and avoid state flicking
@bluebill1049 bluebill1049 moved this from API proposal / RFC to Done in React Hook Form Dec 14, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature request request a feature to be added waiting-up-vote Waiting for votes from the community.
Projects
Development

No branches or pull requests

2 participants