useState(false);
const [items, setItems] = useState([]);
...
setActive(true);
...
setItems([item, ...items]);
2.
const [state, setState] = useState({
isActive: false,
items: []
});
...
setState({
isActive: true,
items: state.items
});
...
setState({
isActive: state.isActive,
items: [item, ...state.items]
});
А не очевидно?
Обсуждают сегодня