I don't quite understand how React toggles booleans. So, I've got two buttons. One console.logs current value of the state(which is set to true) and the other one updates it to opposite(false) and console.logs its value. Problem is that according to console.log of second button state isn't changing, but when I check the state with first button it shows that state was updated.
const App = () => {
const[toggle, setToggle] = useState(true);
return(
<button onClick={()=>{
console.log(toggle)
}}>Button 1</button>
<button onClick={()=>{
setToggle(!toggle)
console.log(toggle)
}}>Button 2</button>
}