Javascript – Why does my react state update on component re render?
I have the following code: const [number, setNumber] = useState(6) function handleClick() { setNumber(5) } ... <Button onClick={handleClick}/> When I click the button, the component displays "5" as desired. But when I close the component and re-open it, it defaults…