Keep components readable, put handlers after jsx
β2 min read
- hoisting
- code-organization
- React 18

The problem
Ui devs are used to writing handlers and components.
Ideally those should be understandable at a first glance.
I'd argue that library hooks and jsx are the most important bits. Thus should be kept at the top and easily accessible.
The answer
Use function declaration syntax and its' hoisting functionality to move repetitive handler logic below jsx and library core functions invocations.
Write like this π
instead of this π₯Ίπ₯β€οΈβπ©Ή
Summary
Javascript's hoisting feature doesn't get the love it deserves. Try out the strategy i've described. You might end up sticking with it π .