Skip to content

Using a suspending query for initial form data #5763

Answered by TkDodo
codebutler asked this question in Q&A
Discussion options

You must be logged in to vote

you can use the reactive values api from react-hook-form:

export const MyPage: React.FC = () => {
  const { data } = useQuery(myFetchFn, { query: { suspense: true, staleTime: 0, cacheTime: 0 } }); 

  const myForm = useForm({
    values: data, // This is reactive
  });

  // etc...
}

https://react-hook-form.com/docs/useform#values

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@codebutler
Comment options

@Cigan12
Comment options

@TkDodo
Comment options

@Cigan12
Comment options

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