2022-08-15
4250
#react
Ohans Emmanuel
356
Aug 15, 2022 ⋅ 15 min read

How to refactor React components to use Hooks

Ohans Emmanuel Visit me at ohansemmanuel.com to learn more about what I do!

Recent posts:

How to fix React routing loopholes with the React Router Middleware

How to fix React routing loopholes with the React Router Middleware

Learn how React Router’s Middleware API fixes leaky redirects and redundant data fetching in protected routes.

Ikeh Akinyemi
Nov 13, 2025 ⋅ 3 min read
How I used Mastra to build a prize-winning RAG agent

How I used Mastra to build a prize-winning RAG agent

A developer’s retrospective on creating an AI video transcription agent with Mastra, an open-source TypeScript framework for building AI agents.

Chinwike Maduabuchi
Nov 13, 2025 ⋅ 12 min read

Ensuring frontend data integrity with TanStack DB transactions

Learn how TanStack DB transactions ensure data consistency on the frontend with atomic updates, rollbacks, and optimistic UI in a simple order manager app.

Emmanuel John
Nov 13, 2025 ⋅ 11 min read
the replay november 12

The Replay (11/12/25): Stop making these useEffect mistakes

Discover what’s new in The Replay, LogRocket’s newsletter for dev and engineering leaders, in the November 5th issue.

Matt MacCormack
Nov 12, 2025 ⋅ 33 sec read
View all posts

4 Replies to "How to refactor React components to use Hooks"

  1. This is the best article that explains well the different react hooks for me. Thanks a lot for this! Btw, do you recommend to omit react-redux over react hooks? Sorry about my grammar.

  2. Hello, thank you for this thorough article. I do have a question about the second example involving the class component with proptypes. I was wondering how/why the refactored code resulted in this:

    App.propTypes = {
    name: PropTypes.number
    }

    Particularly, it is the “PropTypes.number” part of it I don’t understand. Because it first appears as:

    static propTypes = {
    name: PropTypes.string
    }

    Any clarification would be greatly appreciated. Thank you.

Leave a Reply

Hey there, want to help make our blog better?

Join LogRocket’s Content Advisory Board. You’ll help inform the type of content we create and get access to exclusive meetups, social accreditation, and swag.

Sign up now