React Hook Form - How To Persist Form Data In Redux Upon Changes

Viewed 131

I want to store the value of fields, upon update, in a redux state property. Is there a way to do this globally for all the form data or do I need to dispatch a separate reducer for each controlled component upon onChange/onValueChange/onTextChange?

By the way, I'm working in React Native, if that matters (thus using some specific patterns such as control instead of register).


Extra info about my form and redux state: my form has nested children, each containing various custom controlled components. In each of those controlled components, the local form state is updated accordingly (either by passing the new value to setValue if it's a custom input).

After getting my local form data updating properly, I persisted the state in redux by dispatching a reducer in onSubmit. Because this form creates data associated with one item from a list of items, the reducer stores the form data in a parent object located at state.listOfItems[index].formData.

0 Answers
Related