How does the top-level hook rule work within other hooks?
For example, is it OK to inline other hooks like so:
Or do you need to have it like so:
4 Replies
in js world, these two statements are equivalent
both of these satisfy top-level hook rule
Fair, got the response elsewhere that whiile the current setup is valid in regards to the top-level hook rule, it might be good practice to still do alt 2 to avoid someone with not as much react knowledge to come in and do something like:
Rather than
(psuedo code)
Yeah that would be good advice hahaha
👍
Thanks for your answer all the same! 🙏
And as long as you have the eslint rule the beginner would not be allowed to make the change above, so then it should be fine anyway