i am updating my state on onClick
Func but its not updating ,
This is my State
const [loading, setLoading] = useState(false);
my OnCLick func
const handleBookmarkButtonClick = () => {
setLoading(true);
//rest code...including an async func
};
console.log("loading":loading);
the output i got
Object {loading: false }
my OnCLick func
const handleBookmarkButtonClick = () => {
setLoading(true);
//rest code...including an async func
};
console.log("loading":loading);
i am not getting true ,
2
Answers
Create state like this:
And update state like this:
Make sure that: