In this scenario, the 'activeFileName' should be added to a div when it is clicked and removed when another div is clicked.
To achieve this functionality, it is necessary to implement indexing while creating the div elements. For example:
<div
data-index = {1}
onClick={(evt) => { setActiveDiv(evt.target.getAttribute("data-index")}}
className={(activeDiv === 1) ? "activeFileName" : "inActiveFileName"}
>
{item?.name}
</div>
<div
data-index = {2}
onClick={(evt) => { setActiveDiv(evt.target.getAttribute("data-index")}}
className={(activeDiv === 2) ? "activeFileName" : "inActiveFileName"}
>
{item?.name}
</div>
It is possible to assign indexes dynamically using a map or other logical operations.