react-final-form-hooks icon indicating copy to clipboard operation
react-final-form-hooks copied to clipboard

support `decorators`

Open chenjigeng opened this issue 6 years ago • 3 comments

Are you submitting a bug report or a feature request?

feature request

What is the expected behavior?

just like react-final-form.

chenjigeng avatar May 03 '19 06:05 chenjigeng

You can by doing this:

const { form } = useForm({ onSubmit });

calculator(form);

Freddy03h avatar May 17 '19 18:05 Freddy03h

Or, regarding https://github.com/final-form/react-final-form/blob/v5.1.0/src/ReactFinalForm.js#L94, maybe more something like that:

useEffect(() => {
  const unsubscribe = calculator(form);
  return () => unsubscribe();
});

and perhaps we can use this useEffect only on mount

useEffect(() => {
  const unsubscribe = calculator(form);
  return () => unsubscribe();
}, []);

Freddy03h avatar May 17 '19 18:05 Freddy03h

or maybe form

useEffect(() => {
  const unsubscribe = calculator(form);
  return () => unsubscribe();
}, [form]);

Freddy03h avatar May 17 '19 18:05 Freddy03h