In the code snippet below, when I click on Change button to change the value of isLoading ,
nothing happened (isLoading is false).
const App = (props) => {
  const [isLoading, setIsLoading] = useState(false)
  const buttonHandler = () => {
    setIsLoading(current => !current)
    console.log(isLoading) // is false 
  }
  return (
    <div>
      <button onClick={buttonHandler} type="button">
        Change
      </button>
    </div>
  )
}
I tried to change isLoading with the following ways but does not affect:
1-setIsLoading(current => !current)
2-setIsLoading(!isLoading)
3-setIsLoading(true)
 
     
     
     
     
    