Submitted about 2 years agoA solution to the Rock, Paper, Scissors game challenge
Rock Paper Scissors solution with Typescript, React and Tailwind
react, typescript, tailwind-css
LVL 2
@HavreLoic

Solution retrospective
What challenges did you encounter, and how did you overcome them?
I have experienced problem with the asynchronous nature of setState
In React, setState doesn't immediately update the component's state. Instead, React schedules a re-render for later.
This asynchronous behavior allows React to:
Batch state updates to improve performance, especially when multiple rapid state changes occur.
Avoid race conditions by managing updates in a controlled manner.
Solutions:
I used useEffect Hook (for asynchronous operations): The logic that depends on the latest state within a useEffect hook that has the state variable as a dependency:
Code
Loading...
Please log in to post a comment
Log in with GitHubCommunity feedback
No feedback yet. Be the first to give feedback on Havre Loic’s solution.
Join our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord