mercredi 3 mars 2021

React set state condition (if else or ternary) not working. (working even if false)

I'm making a job list challenge in React.

I'm trying to add a filter to show only some properties according our choice.

The goal is to click on one of the component situated on the right.(See attached picture) This component will be showed in the top bar to know on which one we clicked. Here, it's "Frontend". As you can see, there are multiple "Frontend" in the top bar because I clicked on it multiple time

Browser picture

I'm trying to make a condition to avoid that.

For that, I created a hook with [onFilter, setOnFilter]

But no matter the way i'm trying, the if else statement isn't working. IDE picture

I tryied to write the function like 5 to 6 different way.

Can some one have a hint for me ?

I read the documentation and even with that, I don't understand.

Thank you

Antho

Aucun commentaire:

Enregistrer un commentaire