<legend id='Ogdej'><style id='Ogdej'><dir id='Ogdej'><q id='Ogdej'></q></dir></style></legend>
<tfoot id='Ogdej'></tfoot>

  1. <small id='Ogdej'></small><noframes id='Ogdej'>

        <bdo id='Ogdej'></bdo><ul id='Ogdej'></ul>
      <i id='Ogdej'><tr id='Ogdej'><dt id='Ogdej'><q id='Ogdej'><span id='Ogdej'><b id='Ogdej'><form id='Ogdej'><ins id='Ogdej'></ins><ul id='Ogdej'></ul><sub id='Ogdej'></sub></form><legend id='Ogdej'></legend><bdo id='Ogdej'><pre id='Ogdej'><center id='Ogdej'></center></pre></bdo></b><th id='Ogdej'></th></span></q></dt></tr></i><div id='Ogdej'><tfoot id='Ogdej'></tfoot><dl id='Ogdej'><fieldset id='Ogdej'></fieldset></dl></div>

    1. 为什么 React Fibre 会多次调用 componentWillMount?

      Why might componentWillMount be called multiple times with React Fibre?(为什么 React Fibre 会多次调用 componentWillMount?)

        <tfoot id='W1zl4'></tfoot>
        • <i id='W1zl4'><tr id='W1zl4'><dt id='W1zl4'><q id='W1zl4'><span id='W1zl4'><b id='W1zl4'><form id='W1zl4'><ins id='W1zl4'></ins><ul id='W1zl4'></ul><sub id='W1zl4'></sub></form><legend id='W1zl4'></legend><bdo id='W1zl4'><pre id='W1zl4'><center id='W1zl4'></center></pre></bdo></b><th id='W1zl4'></th></span></q></dt></tr></i><div id='W1zl4'><tfoot id='W1zl4'></tfoot><dl id='W1zl4'><fieldset id='W1zl4'></fieldset></dl></div>
          <legend id='W1zl4'><style id='W1zl4'><dir id='W1zl4'><q id='W1zl4'></q></dir></style></legend>

          <small id='W1zl4'></small><noframes id='W1zl4'>

                <bdo id='W1zl4'></bdo><ul id='W1zl4'></ul>
                  <tbody id='W1zl4'></tbody>
                本文介绍了为什么 React Fibre 会多次调用 componentWillMount?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我已经阅读了多个来源,现在使用 react Fiber(异步渲染)componentWillMount() 可能会被多次调用.

                I've read on multiple sources now that with react Fibre (async rendering) componentWillMount() may be called multiple times.

                为什么会这样?

                推荐答案

                Fiber 旨在支持的一件事是高优先级与低优先级更新.例如,动画是高优先级更新(因为很容易注意到 60fps 动画中的抖动),而来自 api 调用的更改将是低优先级(谁会注意到你必须等待的东西多出一百毫秒)还是第二个?).

                One of the things Fibre is intended to support is high priority vs low priority updates. For example, animations are high priority updates (since jankiness in a 60fps animation is easily noticed), while a change from an api call would be be low priority (who's going to notice a extra hundred milliseconds on something you've got to wait a second for anyway?).

                因此,一个简单的示例,仅对 componentWillMount 进行标准调用,如下所示:我们进行低优先级更新,并且协调器开始遍历组件树,在它们上调用 componentWillMount,并进行其他协调工作.由于时间不足,它会暂停以让事件循环恢复.没有高优先级的东西,所以在下一次空闲回调时,它会从中断的地方继续,完成协调并提交更新.没有额外的组件WillMounts.

                So a straightforward example with just the standard one call to componentWillMount is as follows: We do a low priority update, and the reconciler begins working its way through the component tree, calling componentWillMount on them, as well as doing its other reconciliation work. Having run short on time, it pauses to let the event loop resume. There's no high priority stuff, so on the next idle callback, it picks up where it left off, finishes the reconciliation and commits the update. There are no extra componentWillMounts.

                下一个示例:低优先级更新开始,并且和之前一样,协调器通过树对它们调用 componentWillMount 进行工作.和以前一样,它会暂停执行,但这次有高优先级更新.所以当协调恢复时,react 会将注意力转移到高优先级更新上.它协调该更新并提交它.现在可以自由地恢复低优先级更新,但它已经完成的工作需要丢弃,因为高优先级更新可能已经做出了影响低优先级更新将计算的内容的更改.由于它必须重新开始,它需要再次调用 componentWillUpdate.

                Next example: Low priority update starts, and as before the reconciler works through the tree calling componentWillMount on them. As before, it pauses execution, but this time a high priority update comes in. So when reconciliation resumes, react turns its attention to the high priority update. It reconciles that update, and commits it. It's now free to resume the low priority update, but the work it has already done needs to be thrown away, because the high priority update may have made changes that affect what the low priority update will calculate. Since it has to start over, it will need to make those calls to componentWillUpdate again.

                这篇关于为什么 React Fibre 会多次调用 componentWillMount?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Pause youtube video, youtube api(暂停 youtube 视频,youtube api)
                Youtube iframe api not triggering onYouTubeIframeAPIReady(Youtube iframe api 未触发 onYouTubeIframeAPIReady)
                How can I stop a video with Javascript in Youtube?(如何在 Youtube 中停止使用 Javascript 的视频?)
                How to call Greasemonkey#39;s GM_ functions from code that must run in the target page scope?(如何从必须在目标页面范围内运行的代码中调用 Greasemonkey 的 GM_ 函数?)
                How do you mute an embedded Youtube player?(如何使嵌入式 Youtube 播放器静音?)
                How to get number of video views with YouTube API?(如何使用 YouTube API 获取视频观看次数?)
                • <bdo id='s2bu4'></bdo><ul id='s2bu4'></ul>
                    <i id='s2bu4'><tr id='s2bu4'><dt id='s2bu4'><q id='s2bu4'><span id='s2bu4'><b id='s2bu4'><form id='s2bu4'><ins id='s2bu4'></ins><ul id='s2bu4'></ul><sub id='s2bu4'></sub></form><legend id='s2bu4'></legend><bdo id='s2bu4'><pre id='s2bu4'><center id='s2bu4'></center></pre></bdo></b><th id='s2bu4'></th></span></q></dt></tr></i><div id='s2bu4'><tfoot id='s2bu4'></tfoot><dl id='s2bu4'><fieldset id='s2bu4'></fieldset></dl></div>
                    <tfoot id='s2bu4'></tfoot>
                      <tbody id='s2bu4'></tbody>
                    <legend id='s2bu4'><style id='s2bu4'><dir id='s2bu4'><q id='s2bu4'></q></dir></style></legend>

                      <small id='s2bu4'></small><noframes id='s2bu4'>