I am creating a form component with React and want to save the form and field using Redux.
So, I have a form reducer and a formField reducer.
First, I monitored my gut feeling and tried to put the Form reducer in the form reducer. This basically meant the presence of cases related to the form, related to both the screen and the form reducer and formField reducer.
It seemed a bit messy (duplicate code), so I read more in the documentation and found out that it is recommended to normalize the state. So I took the nested formFields and placed them at the same level as the forms.
This made the gearbox nice and clean, but now getting the Fields form for a specific form seems awful. I basically iterate over all Forms Fields every time and return only those that have the correct formId parameter.
The Redux documentation states that you should treat the state as a normalized database, but didnโt he forget that you donโt have the luxury of being able to query the results?
Did I miss something? What is the recommended way to solve this problem?
source share