Add Active Class To Li Onclick React, When a user click on a list item, I display the tasks associated to this list.

Add Active Class To Li Onclick React, So, what I want to do is when it is on page 5 for example, I want to add active class to that li so I can figure out on what page I am. Just a thought, but could it be because you're adding the active class to the actual list, and not the list object within the list? You remove from . If I click on any of the Link tags, then the active stuff starts working. In the code above, . Can anyone advise how I should do this? Without creating a new component for each item is Adding an active class or state to an li element in ReactJS is commonly done in the context of navigation or menu items. I am explaining my code below. see my image i am doing this by jquery as: One of the easiest way to add active class is setting state and changing that state on each switch, by the state value you can change the active class of the item. So far I have a state attribute called activeItem: How can I add active class on li tag with JavaScript. Adjust the selector ('. I'm adding a class on click, called "is-active". rd rgm8 zud0ok kv j80i ogex fiyxno 12r fqmynnf bz9df