React Hook: setState usage
问题 What's the difference between 1 const [state, setState] = useState(0) setState(state+1) 2 const [state, setState] = useState(0) setState(...prevState => prevState+1) 回答1: In the first option, based on the documentation: The setState function is used to update the state. It accepts a new state value and enqueues a re-render of the component. In the second option, called functional update: If the new state is computed using the previous state, you can pass a function to setState . The function