Skip to content
Advertisement

How to change just one parameter using Redux?

I try to update my global state using Redux, but I try to update just one paramter of five, not all.

My store code looks like:

JavaScript

I tried to write a new case like, but doesn’t work:

JavaScript

VS Code doesn’t let me write that “.activated”

My dispatch look like:

JavaScript

What is wrong?

Advertisement

Answer

I understand why you did this, it seemed logical to you, but it will not work.

JavaScript

So your goal is to update the state to be like this:

JavaScript

Firstly, this is the output of what you did:

JavaScript

Secondly, JavaScript doesn’t accept this thisUser.activated as a key.

The solution:

JavaScript
Advertisement