You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since it's not really returning html, and using/modifying most of the state values on app.jsx, the code in Move.jsx should probably just live in App as a useEffect for the app component.
These sort of decisions will start to become clearer the more you use React, but the takeaway here is to treat components as "functions that return jsx"
If you need to modularise the move logic to a different file, you can create a helpers or utils folder and put the handleKeyDown logic in there, and import it into a useEffect inApp. Alternatively, react does offer the ability to write custom hooks
In this case I'd say the useEffect isn't really large enough to warrant moving out to a different function.
The text was updated successfully, but these errors were encountered:
Since it's not really returning html, and using/modifying most of the state values on app.jsx, the code in Move.jsx should probably just live in
App
as a useEffect for the app component.These sort of decisions will start to become clearer the more you use React, but the takeaway here is to treat components as "functions that return jsx"
If you need to modularise the move logic to a different file, you can create a
helpers
orutils
folder and put the handleKeyDown logic in there, and import it into a useEffect inApp
. Alternatively, react does offer the ability to write custom hooksIn this case I'd say the useEffect isn't really large enough to warrant moving out to a different function.
The text was updated successfully, but these errors were encountered: