How to use object spread with nested properties? How to use object spread with nested properties? reactjs reactjs

How to use object spread with nested properties?


Error you are getting because of the this key:

loginForm.email

It's not a valid object key.

Write it like this:

return {     ...state,     loginForm: {        ...state.loginForm,        email: action.payload.email    } }


I think you want something like this:

{ ...state, loginForm: { email: action.payload.email } }