Answer the question
In order to leave comments, you need to log in
How to create a field in state named action?
Good afternoon.
I'm new, I'm asking for help.
An action comes into my reducer with two values: action.name and action.payload.
I need to add a property to the state with the name action.name and the value action.payload
export const BuyReducer = (state = defaultState, action) => {
return{...state,
state[action.name]: action:payload //неверно
}
}
const defaultState = {
Dima: 30
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question