Code Monkey home page Code Monkey logo

Comments (5)

shfshanyue avatar shfshanyue commented on May 13, 2024

依我的看法,React hooks 主要解决了状态以及副作用难以复用的场景,除此之外,他对我最大的好处就是在 Console 中不会看到重重叠叠相同名字的组件了(HOC)。

目前使用感觉最爽的两个hook,都是关于请求的。一个是 apollo-clientuseQuery,一个是 swr

from daily-question.

libin1991 avatar libin1991 commented on May 13, 2024

1.HOC嵌套地狱
2.this
3.逻辑复用
3.tree-shaking

from daily-question.

JeffWong16 avatar JeffWong16 commented on May 13, 2024

个人最喜欢的两个点
1, 再也不用操心讨厌的this的问题
2,逻辑复用更加方便,代码逻辑更加清晰

from daily-question.

Muralitob avatar Muralitob commented on May 13, 2024

不用去写生命周期了

from daily-question.

yangzi0210 avatar yangzi0210 commented on May 13, 2024

1.类组件比起函数组件更难以理解。

2.无需修改组件结构的情况下复用状态逻辑,状态管理更加清晰。

3.不用写类函数就可以使用更多的 React 特性。

4.更符合 React 本身的**,函数式、组件化。

5.组件树层级变浅 (原本的HOC/render props 等方式增加了组件树层数及渲染,在 React DevTools 中观察过 React 应用,你会发现由 providers,consumers,高阶组件,render props 等其他抽象层组成的组件会形成“嵌套地狱”,这些功能都可以通过强大的自定义的 Hooks 来实现。)

6.不用再去考虑 this 的指向、生命周期问题。

from daily-question.

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.