Closed vicentematus closed 2 years ago
Just make an action to push the data into the little state machine
function appendAction(state, payload) {
return {
...state,
data: data.push(payload)
}
}
Should i keep the index [0] or should i change it to work?
Is this okay?:
{...register(
`phisiology_logs[0].date`,
{
required: true,
}
)}
My idea is to push data to an array with the same form. So everytime i press send, it appends it to the array.
Here is my following state:
And this is my form (using react-hook-form)
You can see im just adding this information to the index 0 of the phisiology_logs array. How can i append or push data to the state (data.phisiology_logs[]) object? So everytime i press 'Send' it pushes data to the array.