Код: Выделить всё
const [isChecked, setIsChecked] = useState(false);
const [textStyle, setTextStyle] = useState({ color: 'black' });
const handleCheckboxClick = () => {
setIsChecked(!isChecked);
setTextStyle({ color: isChecked ? 'black' : 'red' });
};
// change the color of the background
return (
Todo List
Add Todo
[list]
{todo.map((item, index) => (
[*]
{item} deleteTodo(index)}>Delete
))}
[/list]
);
}
< /code>
Чего я не понимаю, эта строка специально: < /p>
setTextStyle({ color: isChecked ? 'black' : 'red' });
Подробнее здесь: https://stackoverflow.com/questions/753 ... a-usestate
Мобильная версия