Code Monkey home page Code Monkey logo

Comments (6)

tomvuNexus avatar tomvuNexus commented on September 24, 2024

Hi i have a question.
When you compare between wrapper component and HOC shouldn't the HOC's code shows it returns <Component> instead of <Div> ??

Other than that great write up. Really helps me to understand and differentiate between HOC, wrapper component and the usual component.

from aleksandrhovhannisyan.com.

AleksandrHovhannisyan avatar AleksandrHovhannisyan commented on September 24, 2024

@tomvuNexus Oops, you're right :) Thanks for pointing that out! Fixed.

from aleksandrhovhannisyan.com.

Svish avatar Svish commented on September 24, 2024

Don't really see the point of using HOC anymore though. I feel hooks are so much easier to both read, write, and use. 🤔

from aleksandrhovhannisyan.com.

AleksandrHovhannisyan avatar AleksandrHovhannisyan commented on September 24, 2024

@Svish Hooks are definitely much easier to work with, but you are still going to encounter HOCs in any code base that has class-based components. You can't use hooks in classes.

from aleksandrhovhannisyan.com.

Svish avatar Svish commented on September 24, 2024

That's true. But I would still kind of recommend to never write another HOC again, unless it's absolutely necessary...

from aleksandrhovhannisyan.com.

AleksandrHovhannisyan avatar AleksandrHovhannisyan commented on September 24, 2024

That's fine. This article is intended for people who are interested in understanding HOCs. While it's an older pattern, it's still relevant, and understanding why HOCs were used (or even writing one in modern React) can't possibly hurt anyone. New patterns—including hooks—emerge from old ones.

@Svish Edit: I had some time, so I updated the post to mention hooks. Thanks again for the feedback!

from aleksandrhovhannisyan.com.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.