My question is almost the same as this one.
In this case, the person has a map of states created in a hard coded way:
const App = props => {
const [state, changeState] = useState({
name: "",
eventTitle: "",
details: "",
list: "",
toggleIndex: "",
editName: "",
editEventTitle: "",
editDetails: "",
});
The difference is that I want to create those states dynamically, receiving them from another component. I tried something like this but it obviously did not work:
const App = props => {
const [state, changeState] = useState({
props.inputs.map((input, i) =>
input = ""
)
});
Do you know any solution for this?
props.inputslook like?{ "tag": "1231", "description": "Lorem Ipsum", "inputs": [ "Field1", "Field2", "Field3", "Field4", ] };reducetheprops.inputsinto a new object.