Coder Social home page Coder Social logo

Comments (10)

sanshuiwang avatar sanshuiwang commented on May 22, 2024 4
  1. 编码之前思考
  2. 编码中代码思考,以及借用工具分析
  3. 打包再次处理

砖家威武

from blog.

hufans avatar hufans commented on May 22, 2024

砖家的思维着实缜密。

from blog.

hfuuss avatar hfuuss commented on May 22, 2024

from blog.

acmu avatar acmu commented on May 22, 2024

首先你可以打开这个示例页面

这个页面链接 404 打不开了

from blog.

acmu avatar acmu commented on May 22, 2024

对于不可变数据,我也有一些类似文章里的思考,但还不能像你这样简单的总结出来,砖家牛逼。

还有 useState 的浅比较,真是学到了

from blog.

zingwu avatar zingwu commented on May 22, 2024

牛牛

from blog.

YeeJone avatar YeeJone commented on May 22, 2024

文章很棒~ 纠正一个小问题

也就是执行代码与绘制是同一个线程...

其实浏览器的渲染线程和 js 引擎是两个不同的线程, 并且浏览器 GUI 渲染线程与 JS 引擎是互斥的。

from blog.

liyan1105 avatar liyan1105 commented on May 22, 2024

React 函数组件的 useState,其 setState 会自动做浅比较,也就是如果你在上面例子中调用了 setState(0) ,函数组件会忽略这次更新,并不会执行 render 的。一般在使用的时候要注意这一点,经常有同学掉进这个坑里面。

这里应该不对吧,React应该是用的Object.is的polyfill去做的比较,贴一个源码链接:
https://github.com/facebook/react/blob/3fb11eed9a166ebab23b778662f54c449fcffad0/packages/react-reconciler/src/ReactFiberHooks.new.js#L829

from blog.

wu0792 avatar wu0792 commented on May 22, 2024

React 函数组件的 useState,其 setState 会自动做浅比较,也就是如果你在上面例子中调用了 setState(0) ,函数组件会忽略这次更新,并不会执行 render 的。一般在使用的时候要注意这一点,经常有同学掉进这个坑里面。

这里应该不对吧,React应该是用的Object.is的polyfill去做的比较,贴一个源码链接: https://github.com/facebook/react/blob/3fb11eed9a166ebab23b778662f54c449fcffad0/packages/react-reconciler/src/ReactFiberHooks.new.js#L829

不就是浅比较吗:
https://github.com/facebook/react/blob/3fb11eed9a166ebab23b778662f54c449fcffad0/packages/shared/objectIs.js#L14

from blog.

yysfwls avatar yysfwls commented on May 22, 2024

示例页面打不开

from blog.

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.