When user writes data into a form, and refreshes the page, she loses her data by default. We want to fix that.
So, we need to store the data somewhere, and then repopulate the form with these data after refresh - in our case we shall store the data in browser's local storage.
The logic of saving, retrieving and clearing the persistent data is implemented in persistForm hooks.
- we watch the data changes with react-hook-form watch
- we save the data (debounced) into redux (reducer is defined in formSlice)
- the redux form state is persisted with redux-persist library (it's setup in store)
- we save and delete the data with redux actions
- we select the data with redux selector
see how it's used in OpportunityForm and CloseEventForm