Kizspy | Question: 24
(Choose 1 answer)
FJOVERFLOW.COM
Which method can help ensure that updates in a function depend on the previous state in React?
A. const [count, setCount] = useState(0);
function increment() {
setCount(count + 1);
B. const [count, setCount] = useState(0);
function increment() {
}
setCount(count => count + 1);
C. const [count, setCount] = useState(0);
function increment() {
}
setCount(prevCount => prevCount + 1);
D. const [count, setCount] = useState(0);
function increment() {
}
setCount(count - 1);