DEV Community

Cover image for React Hooks Mini Crash Course

React Hooks Mini Crash Course

Chris Achard on August 30, 2019

This was originally posted as a Twitter thread: https://twitter.com/chrisachard/status/1167132279333957632 Want to learn hooks, but you've been to...
Collapse
 
itsmenatalie profile image
Natalia

This is what I needed this whole time! Easy, clean and descriptive! Thank you mate! 😍

Collapse
 
chrisachard profile image
Chris Achard

You're welcome!

Collapse
 
simbo1905 profile image
Simon Massey • Edited

Do react hooks make it easier to use the mvvm design pattern?

Collapse
 
chrisachard profile image
Chris Achard

Not necessarily easier - hooks are mostly a way to provide functionality to function components (instead of class components), and then they let you re-order and organize how to handle things like effects. So it's not like they allow you to do anything new necessarily - but they just let you organize and respond to your data and effects in a new way.

Collapse
 
landerson352 profile image
Lincoln Anderson

This article may be helpful: medium.com/@thomasburlesonIA/https...

Ignoring the bits about RXJS specifically, the "facade" approach of putting all your "view-model" logic into a custom hook and then pulling the VM hook into the components you need, is pretty great. Previously this would be done with the container/pure-component model and/or higher-order-components (HoCs), which have their own pitfalls and boilerplate to deal with.

So while hooks don't give you any groundbreaking new MVVM architecture out of the box, I do think they make it easier and cleaner to implement.

Collapse
 
chrisachard profile image
Chris Achard

Thanks for the link! I'll check it out

Collapse
 
lmolivera profile image
Lucas Olivera

I've been trying to understand Hooks for a while and this post basically explained me how to use them. Thank you very much, it is a very well written article!

Collapse
 
chrisachard profile image
Chris Achard

Thanks! I really like the format as well: Hopefully I'll do more! I like the "mini crash course" idea, plus it fits well for both twitter and for here.

Glad it was helpful!

Collapse
 
s_aitchison profile image
Suzanne Aitchison

Thanks for this - it's the perfect overview I needed!

Collapse
 
chrisachard profile image
Chris Achard

Glad it helped!