Answer the question
In order to leave comments, you need to log in
How to add a new object inside an array in state in Redux?
There is an array of objects as a parameter of the User object. How to write a handler for adding an object in a reducer as shown in the diagram below? Please tell me
state
-- user:
----name: 'bla-bla'
----patients: ['how to add an object here?']
The state with the user object comes to the input of the reducer
Answer the question
In order to leave comments, you need to log in
Is this the right way for redux? Or are there other options?
case types.ADD_NEW_PATIENT:
var patients = state.patients
patients.push(action.patient)
return {
...state,
patients: patients
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question