James Xabregas
1 min readOct 17, 2022

--

In a nutshell the biggest issue with React Hooks is that they are difficult to reason about. They look simpler in code examples because they are simpler from a syntax perspective but as soon as things progress to even medium complexity they are a nightmare to deal with. I’ve had to deal with existing code bases where a single functional component had more than 20 different hook calls and it was just painful.
Honestly I think developers should use class components most of the time and should only use functional components when dealing with dumb presentation layer only components. For example it’s perfectly fine if you’re creating a styled button component or something similar and you’re just passing in some basic props. If however you need to start fetching data and managing state you really should be refactoring to a class component. Occasionally I’ve had the need to use functionality from a library that is only available as a hook, and in those occasions I’ve simply wrapped my class component with a very simple functional component that passed the hook values down to the class component as props. In general though I think functional components should be avoided because it leads to sloppy unreadable code.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

James Xabregas
James Xabregas

Written by James Xabregas

Manipulating electrons for fun and profit. Thoughts on tech, startups, politics, life. Co-founder of Braiv.co

Responses (1)

Write a response