mardi 6 juillet 2021

react className conditional setting according to all of state

I currently making a vocabulary website and got state from mysql, and the state is like this.

1: memorize : 0
2: memorize : 0
3: memorize : 0
4: memorize : 0
5: memorize : 1
6: memorize : 0

So if I check the checkbox on the list of website, each state turns to 1. and 0 means not checked. every time check the box, it changes the value of state(from0 to 1)

and what I want to make is the button(finish) that active&disable. If all of the state turn in to 1, I want to make this finish button active. So I decided to make 2 className, active, notActive, however it is really hard to make the condition.

How to use "If" structure to examine all state? I have tried using State.map, but this only works when examine each state, not whole.

in conclusion, I want to make

  useEffect(() =>{if( all of the state === 1){ buttonClassName = active}}

could you tell me how to embody"all of the state" ?

Aucun commentaire:

Enregistrer un commentaire