performance - React 是否只重新渲染改变了渲染速度的内容?

标签 performance reactjs browser

为什么 React 的“只更新必要的”功能对性能很重要?
来自 https://facebook.github.io/react/docs/rendering-elements.html#react-only-updates-whats-necessary

React only updating what has changed.

React 仅重新渲染已更改组件的功能是否会影响浏览器渲染速度/性能?

React 声称只更新需要更新的 UI 组件,而不是整个页面,可以提高性能。来自 https://facebook.github.io/react/docs/optimizing-performance.html

Internally, React uses several clever techniques to minimize the number of costly DOM operations required to update the UI. For many applications, using React will lead to a fast user interface without doing much work to specifically optimize for performance.



在应用程序的更新/绘制循环中,不是必须重新绘制整个屏幕吗?如果浏览器必须在每一帧都重绘所有元素,那么它如何从仅渲染(重绘?)元素中的一个元素中受益?浏览器有一个帧率( MDN Frame Rate ),那么帧率如何与“只更新必要的内容”相协调?

我没有看到仅更新浏览器中的一个元素会如何影响浏览器的绘制。在实际推送渲染之前,React 的 javascript 对象表示可能很快,但如果 R​​eact 仅渲染与实际 DOM 的差异,这对性能有何帮助?

一个较低级别的问题可能是:当不重新绘制/重排布局时,浏览器如何节省计算?它不是必须绘制每一帧吗?

我已经提到了这些其他话题,但没有专门解决我的问题:
  • How React.js speeds up rendering with a virtual DOM
  • Does the browser re-render the whole page on changes or only the specific elements?
  • 最佳答案

    您自己在这里引用了答案:

    Internally, React uses several clever techniques to minimize the number of costly DOM operations required to update the UI. For many applications, using React will lead to a fast user interface without doing much work to specifically optimize for performance.



    React 并不关心优化低级问题,例如如何重绘页面(这可能由操作系统本身处理),而是如何有效地使用 DOM。众所周知,执行的 DOM 操作越多,整体性能就越差。 React 只是为了最小化那些 DOM 操作。

    关于performance - React 是否只重新渲染改变了渲染速度的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44767312/

    相关文章:

    c# - C# .NET 4.0 中的数据绑定(bind)设置时间缓慢

    reactjs - 获取状态并从中间件进行调度

    html - 如何使浏览器显示对静态站点的更改

    google-chrome - 有没有办法恢复已删除的 chrome 缓存文件?

    reactjs - react : Best way to put dummy content in a component

    browser - 在 Vaadin 14 应用程序的服务器端通过 Java 获取用户 Web 浏览器的 IP 地址

    multithreading - diff 文件夹递归与多线程

    performance - 为什么交叉应用比内连接快?

    sql服务器: Get OHLC in one query with n recodrs

    javascript - Object.create 有哪些替代方案(将状态设置为 React 组件时)?