DEV Community

Discussion on: Refactor a form with React Hooks and useState

Collapse
 
saulsilver profile image
Hatem Houssein

Merci beaucoup pour l'explication, really helpful comparison!

Is there a reason why you initialized setValues after the handleInputChange() and AddItem() functions, or is it just a personal preference?

Collapse
 
damcosset profile image
Damien Cosset

When I first started with hooks, I declared them last. Nowadays, I do declare them first :D
Personal preferences 😉

Collapse
 
saulsilver profile image
Hatem Houssein

Yeah Dan (from React) suggested declaring them at the top so I do the same and was just wondering.

Thanks!