React
The library for web and native user interfaces.Methods
(static) useEffect()
React useState hook is asynchronous!
Basically, you don't get update value right after updating state.
The useEffect hook executes after the function returns the generated component instance within it, which means that any ref or state will be assigned before the useEffect hook gets called.This code will always use the latest value of clicked, which will be used in the next draw.