You are viewing a single comment's thread. Return to all comments →
assuming that you've set up this state with:
const [upvotes, setUpvotes] = useState(0);
your function handling the click should call:
setUpvotes(upvotes+1)
while your upvotes display should just display {upvotes}
{upvotes}
This should trigger state setting and rerender immediatelly upon click.
Seems like cookies are disabled on this browser, please enable them to open this website
Code Review Feedback
You are viewing a single comment's thread. Return to all comments →
assuming that you've set up this state with:
const [upvotes, setUpvotes] = useState(0);
your function handling the click should call:
setUpvotes(upvotes+1)
while your upvotes display should just display
{upvotes}
This should trigger state setting and rerender immediatelly upon click.