#Worth updating the docs?

4 messages · Page 1 of 1 (latest)

lyric path
#

Hey, I was taking a look at react query example at: https://github.com/mantinedev/mantine/blob/master/apps/mantine.dev/src/pages/form/values.mdx. I am doing something very similar. In that example form is missing in the useEffect dependencies array. My linter is complaining about form not being part of the dependency array, I legit wonder if it's a good idea for my to open an improvement PR to update the docs to something like:

useEffect(() => {
  if (query.data) {
    if(!form.initialized) {
      // Even if query.data changes, form will be initialized only once
      form.initialize(query.data);
    }
  }
}, [form, query.data]);

If check is needed to prevent form.initialize from triggering the same effect over and over.

vague kayak
#

if you subscribe to the form, every time the form updates you'll trigger the effect function to rerun

#

it's redundant to do this as we're only interested in query data in this case