- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我知道 shouldComponentUpdate()
在返回 false 时会阻止调用 render()
方法。如果我在 render()
方法中使用一些昂贵的逻辑,那么 shouldComponentUpdate()
是一个非常有用的东西,因为我可以阻止 render()
打电话。
但是,如果我的 render()
方法只返回 Element
,而不执行任何昂贵的代码,那会怎样呢?
shouldComponentUpdate()
中的比较(让我们以 PureComponent 的实现为例)和 render()
调用时内置的 React diffing 之间有什么区别吗?
最佳答案
我觉得这里写的很棒: https://reactjs.org/docs/reconciliation.html
主要区别在于 React.PureComponent 在旧 props 和新 props 之间以及旧状态和新状态之间进行了浅层比较,但是内置的 React diffing(reconcilation)简要地比较了新旧 DOM 树,但请阅读上面这篇文章,它将解决您的疑惑。
关于javascript - shouldComponentUpdate 和内置 diffing 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53257997/
这个问题在这里已经有了答案: Is floating point math broken? (31 个答案) 关闭 4 年前。 我正在尝试编写一个程序,将分数 m/n 写为不同埃及分数 (EF) 的
我正在创建一个业务选项表单(我知道粗略的描述,但这里是)。我希望弹出的第一个 select 是选择实体类型(即:Corporation、LLC、LLP 等)。选择其中一个后,我想.show() 下一个
我正在寻找一个可以读取从 Excel 保存的 *.dif 文件的 Java 库 http://en.wikipedia.org/wiki/Data_Interchange_Format 有什么可以帮助
这是在现实世界中出现的,我想我会分享它,因为它可能会导致一些有趣的解决方案。本质上,该算法需要区分两个列表,但让我给你一个更严格的问题定义。 数学公式 假设您有两个列表,L 和 R,每个列表都包含来自
我知道 shouldComponentUpdate() 在返回 false 时会阻止调用 render() 方法。如果我在 render() 方法中使用一些昂贵的逻辑,那么 shouldCompone
Apache 正在做一些非常奇怪的事情。起初,我的浏览器似乎总是在加载缓存副本。我通过禁用缓存、使用新浏览器和使用 curl 排除了这种情况,我 100% 确信这不是客户端缓存问题。 我有一个内容非常
我的问题是关于 Motivation用于实现启发式 O(n) 算法。 There are some generic solutions to this algorithmic problem ofge
我正在学习“Prolog by Example”一书中的一个例子(Helder Coelho 和 Jose C Cotta)。 Write a program for designing an arc
站等待以检测信道是否空闲 DIFS,然后开始传输。我的问题是为什么只等待 DIFS 而不是 SIFS。 它可能导致什么问题(对 SIFS 而不是 DIFS 的意义)? 最佳答案 简短回答: SIFS不
我这里有一个小型聊天应用程序。 我可以有两种类型的消息: - 文本 - 视频 我在解码 JSON 时使用多态性,如下所示: import Foundation enum MessageType: In
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 11 年前。 Improve thi
我正在谈论reactJS中的协调 我阅读了 React Documentation 上的这一部分,react 说 -> 当比较两棵树时,React 首先比较两个根元素。根据根元素的类型,行为会有所不同
使用 msysgit在 Windows 上,每当我在具有一个或多个子模块的存储库上执行 git diff 时,命令提示符(以及 PowerShell)都会崩溃。 这是已知问题吗?是否有修复/解决方法?
这有什么区别: X \= Y 和这段代码: dif(X, Y) 我认为他们应该表现得一样,但他们没有。这是示例: n_puta(L, N, X) :- nputa(L, N, 0, X). nputa
是否可以在 git diff --color-words 的同时不区分大小写 git diff?或者我是否需要在执行 git diff --color-words 时使用外部差异程序? (注意:如果你
我正在尝试一个新的分层线性模型,但数据结构让我想知道这在 R 中是否可行。我之前对模型的尝试被错误地指定(哎呀),现在我不知道如何处理这部分工作。我的 HLM 类(class)涵盖了多级模型和交叉分类
今天多次成功编译清理构建后,突然出现Netbeans 8.0.2错误: Unable to delete file C:\Users\Dov\Google Drive\NetBeansProjects
我是一名优秀的程序员,十分优秀!