Answer the question
In order to leave comments, you need to log in
How to change styles on a specific React child element?
How to change the styles of a specific child element that was clicked on on click?
Here is my code:
<div>
{arr.map((res, key) => (
<span key={key} onClick('что здесь писать?') className={'elem'}>{res + 1} элемент</span>
))}
</div>
Answer the question
In order to leave comments, you need to log in
If the logic for receiving data is very similar, and only, for example, addresses for the API change, then you can do everything in one place. If the differences are large enough, then it is better to split it so that it is easier to maintain later.
handleClick=(e)=>{
e.preventDefault();
e.target.style.color = 'black'
console.log(e.target);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question