I'm working on a recursive form based on a nested object, using React and MUI, and I'm to keeping track of the previous keys during the recursion.
At some point, as the user changes the form, I need to change the corresponding nested, state object.
So, I would need, in order to access the value in the form, some way of doing something similar to this:
const keyList = [k1, k2, ..., kn]
form[k1][k2]...[kn]
And, in the same vein, in order to set the value:
<TextField
onChange={(e) => {
const newForm = { ...form }
newForm[k1][k2]...[kn] = newValue
setForm(newForm)
}}
/>
Is there a way of dealing with this? If so, how?