79541054

Date: 2025-03-28 09:47:59
Score: 1
Natty:
Report link

Why is hello from provider printed last?

Order of Hook Execution: When the Game component is rendered, it first executes the custom hook useHoo, which runs any useEffect inside it.

Provider's useEffect: The useEffect in GameProvider will fire after the component has rendered and React has finished processing all the hooks in game.jsx.

Effect Execution Order: React schedules effects to run after the render phase, so the order of execution you’re observing is because React first runs the useEffect in useHoo, then runs the one in Game, and finally the one in GameProvider.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Starts with a question (0.5): Why is
  • Low reputation (1):
Posted by: Thearoth