Q:

Use useState correctly

I see some people update state using hook like this:
const [count, setCount] = useState(0)

Way 1: setCount(count + 1)
Way 2: setCount(count => count + 1)
What is the difference between these 2 ways?

A:

From the docs:

State Updates May Be Asynchronous 
React may batch multiple setState()
  calls into a single update for performance.
Because this.props and this.state may be updated asynchronously, you
  should not rely on their values for calculating the next state.

Therefore when updating the state based on the value of the current state it is better to use the callback version. 
const [count, setCount] = useState(0); // initial state is 0

If you e.g. update the state multiple times like that in a single handler:
setCount(count + 1); 
// new state will be 1 

setCount(count + 1); 
// new state will still be 1 because updates are async 
// and `count` still is 0 at the time of calling this

Whereas 
setCount(count => count + 1); 
// new state will be 1

setCount(count => count + 1); 
// new state will be 2 because the value passed 
// to the callback will include the previous update

If you want to be safe always use a callback when updating based on the current state.
More information can be found in the docs.

