Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<Move/> doesn't really need to be a component #20

Open
rooberrydev opened this issue Feb 11, 2022 · 0 comments
Open

<Move/> doesn't really need to be a component #20

rooberrydev opened this issue Feb 11, 2022 · 0 comments

Comments

@rooberrydev
Copy link

rooberrydev commented Feb 11, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant