Answer the question
In order to leave comments, you need to log in
How to change so that only one element changes on click?
I make the empty flag become painted over when clicking on the button in which it is located, but now everything changes at once, I tried to pass id as a key, the picture is still the same, now the code looks like this
const [check, setCheck] = useState(false);
<td>
<button
onClick={() => {
setCheck((prevCheck) => !prevCheck);
}}
>
{Bookmark(check)}
</button>
</td>
const Bookmark = (status) => {
if (status === false) {
return <i className="bi bi-bookmark"></i>;
} else if (status === true) {
return <i className="bi bi-bookmark-fill"></i>;
}
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question