Skip to content

Question regarding last blog post #5740

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

You must be logged in to vote

you still need local state to perform ephemeral updates. You're looking at "form state", which gets initialized with values from the server. Have a read at: https://tkdodo.eu/blog/react-query-and-forms

in your contrived example, I'd do:

const [issues, setIssues] = React.useState()

const { data } = useQuery({
  queryKey: ['issues'],
  queryFn: ()=> axios.get('/issues').then(res => res.data)
})

const inputValue = issues ?? data.inputValue

<input value={inputValue} onChange={e => setIssues(e.target.value) } />

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@gmcamposano
Comment options

Answer selected by gmcamposano
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