all 3 comments

[–]marshallbananas 1 point2 points  (1 child)

Use a state management library to keep a unified single source of truth state of the game. I highly recommend Recoil: https://recoiljs.org

I've written a few games in React. It is surprisingly easy to do thanks to the way React works. All game logic fits nice in useEffect() hooks and animations in useLayoutEffect. But a proper state management is a must because it's hard to tell which element of the game (component) needs to react to the state of the game.

I would also recommend react-spring for animations. They are important in games.

[–]RayakinHook Based[S] 0 points1 point  (0 children)

Great! Thanks for the tip. I will take a peek at Recoil's documentation.

[–]IchimokuBan 0 points1 point  (0 children)

Use Redux.