Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use closures in DevTools injection #18278

Merged
merged 2 commits into from Apr 9, 2020

Conversation

sebmarkbage
Copy link
Collaborator

@sebmarkbage sebmarkbage commented Mar 11, 2020

Nested closures are tricky. They're not super efficient and when they share scope between multiple closures they're hard for a compiler to optimize. It's also unclear how many versions will be created.

By hoisting things out an just make it simple calls the compiler can do a much better job.

Before

"function" === typeof ik && ik(c.stateNode, d);
"function" === typeof Qi && Qi(b);
var ik = null,
  Qi = null;
function nk(a) {
  if ("undefined" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) return !1;
  var b = __REACT_DEVTOOLS_GLOBAL_HOOK__;
  if (b.isDisabled || !b.supportsFiber) return !0;
  try {
    var c = b.inject(a);
    ik = function(a) {
      try {
        b.onCommitFiberRoot(c, a, void 0, 64 === (a.current.effectTag & 64));
      } catch (e) {}
    };
    Qi = function(a) {
      try {
        b.onCommitFiberUnmount(c, a);
      } catch (e) {}
    };
  } catch (d) {}
  return !0;
}
(function(a) {
  var b = a.findFiberByHostInstance;
  return nk(
    n({}, a, {
      overrideHookState: null,
      overrideProps: null,
      setSuspenseHandler: null,
      scheduleUpdate: null,
      currentDispatcherRef: Wa.ReactCurrentDispatcher,
      findHostInstanceByFiber: function(a) {
        a = ic(a);
        return null === a ? null : a.stateNode;
      },
      findFiberByHostInstance: function(a) {
        return b ? b(a) : null;
      },
      findHostInstancesForRefresh: null,
      scheduleRefresh: null,
      scheduleRoot: null,
      setRefreshHandler: null,
      getCurrentFiber: null
    })
  );
})({
  findFiberByHostInstance: uc,
  bundleType: 0,
  version: "16.13.0",
  rendererPackageName: "react-dom"
});

After

  if ("function" === typeof ik)
    try {
      ik(Qi, c, void 0, 64 === (c.current.effectTag & 64));
    } catch (ya) {}
  if ("function" === typeof Pi)
    try {
      Pi(Qi, b);
    } catch (e) {}
var Dk = {
    findFiberByHostInstance: tc,
    bundleType: 0,
    version: "16.13.0",
    rendererPackageName: "react-dom"
  };
var Ek = {
  bundleType: Dk.bundleType,
  version: Dk.version,
  rendererPackageName: Dk.rendererPackageName,
  getInspectorDataForViewTag: Dk.getInspectorDataForViewTag,
  overrideHookState: null,
  overrideProps: null,
  setSuspenseHandler: null,
  scheduleUpdate: null,
  currentDispatcherRef: Ya.ReactCurrentDispatcher,
  findHostInstanceByFiber: function(a) {
    a = hc(a);
    return null === a ? null : a.stateNode;
  },
  findFiberByHostInstance: Dk.findFiberByHostInstance || tk,
  findHostInstancesForRefresh: null,
  scheduleRefresh: null,
  scheduleRoot: null,
  setRefreshHandler: null,
  getCurrentFiber: null
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
  var Fk = __REACT_DEVTOOLS_GLOBAL_HOOK__;
  if (!Fk.isDisabled && Fk.supportsFiber)
    try {
      (Qi = Fk.inject(Ek)),
        (ik = Fk.onCommitFiberRoot),
        (Pi = Fk.onCommitFiberUnmount);
    } catch (a) {}
}

Note that it's still sub-optimal because the config object gets created even though it should be able to be inlined by Closure Compiler. We should really switch this per-renderer config object to be a HostConfig the whole thing instead to avoid that.

The injected object is also created outside the condition so it's always created even if no devtools is present.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Mar 11, 2020
@codesandbox-ci
Copy link

codesandbox-ci bot commented Mar 11, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 0c43f3e:

Sandbox Source
aged-wave-01t84 Configuration

@sizebot
Copy link

sizebot commented Mar 11, 2020

Details of bundled changes.

Comparing: 5474a83...0c43f3e

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js -0.1% -0.1% 652.97 KB 652.51 KB 136.99 KB 136.9 KB UMD_DEV
react-art.production.min.js -0.0% -0.1% 109.74 KB 109.73 KB 33.13 KB 33.11 KB UMD_PROD
react-art.development.js -0.1% -0.1% 556.54 KB 556.1 KB 119.47 KB 119.37 KB NODE_DEV
react-art.production.min.js -0.1% -0.0% 74.71 KB 74.66 KB 22.33 KB 22.32 KB NODE_PROD
ReactART-dev.js -0.1% -0.1% 588.62 KB 588.26 KB 123.47 KB 123.4 KB FB_WWW_DEV
ReactART-prod.js 0.0% 🔺+0.1% 240.77 KB 240.79 KB 40.65 KB 40.69 KB FB_WWW_PROD

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactTestRenderer-dev.js -0.1% -0.1% 575.72 KB 575.36 KB 121.41 KB 121.33 KB FB_WWW_DEV
react-test-renderer-shallow.development.js 0.0% -0.0% 38.72 KB 38.72 KB 9.43 KB 9.43 KB UMD_DEV
react-test-renderer-shallow.production.min.js 0.0% 0.0% 12.74 KB 12.74 KB 3.97 KB 3.97 KB UMD_PROD
react-test-renderer.development.js -0.1% -0.1% 568.39 KB 567.93 KB 118.2 KB 118.11 KB UMD_DEV
react-test-renderer.production.min.js -0.0% -0.1% 74.17 KB 74.16 KB 22.56 KB 22.54 KB UMD_PROD
react-test-renderer.development.js -0.1% -0.1% 541.96 KB 541.52 KB 116.86 KB 116.76 KB NODE_DEV
react-test-renderer.production.min.js -0.1% -0.0% 74 KB 73.96 KB 22.25 KB 22.25 KB NODE_PROD

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom-server.browser.development.js 0.0% -0.0% 156.59 KB 156.59 KB 39.58 KB 39.58 KB UMD_DEV
react-dom-server.browser.production.min.js 0.0% -0.0% 23.39 KB 23.39 KB 8.6 KB 8.6 KB UMD_PROD
react-dom.profiling.min.js -0.0% -0.0% 127.81 KB 127.78 KB 39.89 KB 39.88 KB NODE_PROFILING
ReactDOM-dev.js -0.0% -0.0% 979.55 KB 979.19 KB 217.13 KB 217.06 KB FB_WWW_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.1% 1.2 KB 1.2 KB 706 B 705 B UMD_PROD
ReactDOM-prod.js 0.0% 🔺+0.1% 408.56 KB 408.63 KB 73.9 KB 73.95 KB FB_WWW_PROD
ReactDOM-profiling.js 0.0% +0.1% 419.38 KB 419.47 KB 75.75 KB 75.79 KB FB_WWW_PROFILING
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 4.43 KB 4.43 KB 1.54 KB 1.55 KB NODE_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.2% 1.02 KB 1.02 KB 618 B 617 B NODE_PROD
react-dom-test-utils.development.js 0.0% -0.0% 75.14 KB 75.14 KB 20.12 KB 20.11 KB UMD_DEV
ReactDOMTesting-dev.js -0.0% -0.0% 929.91 KB 929.55 KB 207.15 KB 207.06 KB FB_WWW_DEV
ReactDOMTesting-prod.js 0.0% 0.0% 393.2 KB 393.25 KB 71.65 KB 71.67 KB FB_WWW_PROD
react-dom-test-utils.development.js 0.0% -0.0% 69.98 KB 69.98 KB 19.61 KB 19.61 KB NODE_DEV
ReactDOMTesting-profiling.js 0.0% 0.0% 393.2 KB 393.25 KB 71.65 KB 71.67 KB FB_WWW_PROFILING
react-dom-server.node.development.js 0.0% -0.0% 148.58 KB 148.58 KB 39.1 KB 39.1 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% -0.0% 13.1 KB 13.1 KB 4.81 KB 4.81 KB NODE_PROD
react-dom-server.node.production.min.js 0.0% -0.0% 23.69 KB 23.69 KB 8.72 KB 8.72 KB NODE_PROD
react-dom-server.browser.development.js 0.0% -0.0% 147.36 KB 147.36 KB 38.84 KB 38.84 KB NODE_DEV
react-dom-server.browser.production.min.js 0.0% -0.0% 23.28 KB 23.28 KB 8.57 KB 8.56 KB NODE_PROD
react-dom.development.js -0.0% -0.1% 935.65 KB 935.19 KB 204.05 KB 203.95 KB UMD_DEV
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 56.11 KB 56.11 KB 13.85 KB 13.85 KB UMD_DEV
react-dom.production.min.js -0.0% -0.1% 123.63 KB 123.6 KB 39.42 KB 39.4 KB UMD_PROD
ReactDOMForked-dev.js -0.0% -0.0% 979.55 KB 979.19 KB 217.13 KB 217.06 KB FB_WWW_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.1% 10 KB 10 KB 3.36 KB 3.36 KB UMD_PROD
ReactDOMServer-dev.js 0.0% -0.0% 154.48 KB 154.48 KB 38.97 KB 38.97 KB FB_WWW_DEV
react-dom.profiling.min.js -0.0% -0.0% 127.47 KB 127.45 KB 40.63 KB 40.62 KB UMD_PROFILING
ReactDOMForked-prod.js 0.0% 🔺+0.1% 408.56 KB 408.63 KB 73.9 KB 73.95 KB FB_WWW_PROD
ReactDOMServer-prod.js 0.0% -0.0% 52.56 KB 52.56 KB 12.68 KB 12.68 KB FB_WWW_PROD
react-dom.development.js -0.0% -0.0% 890.89 KB 890.46 KB 201.58 KB 201.48 KB NODE_DEV
ReactDOMForked-profiling.js 0.0% +0.1% 419.38 KB 419.47 KB 75.75 KB 75.79 KB FB_WWW_PROFILING
react-dom.production.min.js -0.0% -0.0% 123.83 KB 123.78 KB 38.62 KB 38.61 KB NODE_PROD
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.1% 9.75 KB 9.75 KB 3.26 KB 3.25 KB NODE_PROD
react-dom-unstable-fizz.node.production.min.js 0.0% -0.3% 1.17 KB 1.17 KB 668 B 666 B NODE_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-prod.js 0.0% 🔺+0.1% 270.91 KB 270.93 KB 46.57 KB 46.6 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js 0.0% +0.1% 282.28 KB 282.34 KB 48.74 KB 48.77 KB RN_OSS_PROFILING
ReactFabric-prod.js 0.0% 🔺+0.1% 262.89 KB 262.91 KB 45.05 KB 45.08 KB RN_OSS_PROD
ReactFabric-profiling.js 0.0% +0.1% 274.27 KB 274.33 KB 47.22 KB 47.26 KB RN_OSS_PROFILING
ReactFabric-dev.js -0.1% -0.1% 639.96 KB 639.59 KB 136.64 KB 136.57 KB RN_FB_DEV
ReactFabric-prod.js 0.0% 🔺+0.1% 263.04 KB 263.06 KB 45.09 KB 45.12 KB RN_FB_PROD
ReactNativeRenderer-dev.js -0.1% -0.1% 653.75 KB 653.39 KB 140.33 KB 140.25 KB RN_OSS_DEV
ReactFabric-profiling.js 0.0% +0.1% 274.42 KB 274.47 KB 47.25 KB 47.29 KB RN_FB_PROFILING
ReactNativeRenderer-dev.js -0.1% -0.1% 658.24 KB 657.88 KB 141.08 KB 141 KB RN_FB_DEV
ReactNativeRenderer-prod.js 0.0% 🔺+0.1% 271.05 KB 271.07 KB 46.6 KB 46.63 KB RN_FB_PROD
ReactNativeRenderer-profiling.js 0.0% +0.1% 282.42 KB 282.48 KB 48.77 KB 48.8 KB RN_FB_PROFILING
ReactFabric-dev.js -0.1% -0.1% 635.46 KB 635.1 KB 135.9 KB 135.82 KB RN_OSS_DEV

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler-reflection.development.js 0.0% -0.0% 16.23 KB 16.23 KB 4.92 KB 4.92 KB NODE_DEV
react-reconciler-reflection.production.min.js 0.0% -0.2% 2.58 KB 2.58 KB 1.09 KB 1.09 KB NODE_PROD
react-reconciler.development.js -0.1% -0.1% 598.26 KB 597.83 KB 126.17 KB 126.06 KB NODE_DEV
react-reconciler.production.min.js -0.0% 0.0% 80.08 KB 80.07 KB 23.56 KB 23.57 KB NODE_PROD

ReactDOM: size: 0.0%, gzip: -0.0%

Size changes (experimental)

Generated by 🚫 dangerJS against 0c43f3e

@sizebot
Copy link

sizebot commented Mar 11, 2020

Details of bundled changes.

Comparing: 5474a83...0c43f3e

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js -0.1% -0.1% 632.6 KB 632.14 KB 133.29 KB 133.2 KB UMD_DEV
react-art.production.min.js -0.0% -0.1% 107.13 KB 107.12 KB 32.46 KB 32.44 KB UMD_PROD
react-art.development.js -0.1% -0.1% 536.98 KB 536.54 KB 115.72 KB 115.64 KB NODE_DEV
react-art.production.min.js -0.1% -0.0% 72.15 KB 72.11 KB 21.66 KB 21.66 KB NODE_PROD
ReactART-dev.js -0.1% -0.1% 598.69 KB 598.33 KB 125.46 KB 125.39 KB FB_WWW_DEV
ReactART-prod.js 0.0% 🔺+0.1% 248.21 KB 248.24 KB 41.94 KB 41.97 KB FB_WWW_PROD

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-test-renderer.development.js -0.1% -0.1% 568.36 KB 567.9 KB 118.18 KB 118.09 KB UMD_DEV
react-test-renderer.production.min.js -0.0% -0.1% 74.15 KB 74.13 KB 22.54 KB 22.52 KB UMD_PROD
react-test-renderer-shallow.development.js 0.0% -0.0% 38.71 KB 38.71 KB 9.42 KB 9.42 KB UMD_DEV
react-test-renderer-shallow.production.min.js 0.0% 0.0% 12.73 KB 12.73 KB 3.96 KB 3.97 KB UMD_PROD
react-test-renderer.development.js -0.1% -0.1% 541.93 KB 541.5 KB 116.84 KB 116.75 KB NODE_DEV
react-test-renderer.production.min.js -0.1% -0.0% 73.97 KB 73.93 KB 22.23 KB 22.23 KB NODE_PROD
ReactTestRenderer-dev.js -0.1% -0.1% 575.71 KB 575.35 KB 121.4 KB 121.33 KB FB_WWW_DEV

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-dev.js -0.1% -0.1% 653.74 KB 653.38 KB 140.32 KB 140.24 KB RN_OSS_DEV
ReactNativeRenderer-prod.js 0.0% 🔺+0.1% 270.89 KB 270.91 KB 46.56 KB 46.59 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js 0.0% +0.1% 282.27 KB 282.33 KB 48.73 KB 48.76 KB RN_OSS_PROFILING
ReactFabric-dev.js -0.1% -0.1% 635.45 KB 635.09 KB 135.9 KB 135.82 KB RN_OSS_DEV
ReactFabric-prod.js 0.0% 🔺+0.1% 262.88 KB 262.9 KB 45.04 KB 45.07 KB RN_OSS_PROD
ReactFabric-profiling.js 0.0% +0.1% 274.25 KB 274.31 KB 47.22 KB 47.25 KB RN_OSS_PROFILING

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.production.min.js -0.0% -0.1% 119.69 KB 119.64 KB 37.52 KB 37.5 KB NODE_PROD
react-dom-test-utils.development.js 0.0% -0.0% 75.12 KB 75.12 KB 20.11 KB 20.11 KB UMD_DEV
ReactDOMTesting-profiling.js 0.0% 0.0% 405.02 KB 405.08 KB 73.45 KB 73.46 KB FB_WWW_PROFILING
react-dom-server.browser.production.min.js 0.0% -0.0% 22.82 KB 22.82 KB 8.49 KB 8.48 KB NODE_PROD
react-dom.profiling.min.js -0.0% 0.0% 123.54 KB 123.51 KB 38.66 KB 38.67 KB NODE_PROFILING
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.3% 1.19 KB 1.19 KB 699 B 697 B UMD_PROD
react-dom-server.node.development.js 0.0% -0.0% 147.06 KB 147.06 KB 38.89 KB 38.88 KB NODE_DEV
react-dom-server.node.production.min.js 0.0% -0.0% 23.23 KB 23.23 KB 8.65 KB 8.65 KB NODE_PROD
ReactDOMForked-dev.js -0.0% -0.0% 1007.43 KB 1007.07 KB 223.11 KB 223.05 KB FB_WWW_DEV
ReactDOMForked-prod.js 0.0% 0.0% 421.47 KB 421.54 KB 75.8 KB 75.83 KB FB_WWW_PROD
react-dom.development.js -0.1% -0.1% 905.73 KB 905.27 KB 198.78 KB 198.67 KB UMD_DEV
ReactDOMForked-profiling.js 0.0% 0.0% 432.35 KB 432.44 KB 77.69 KB 77.72 KB FB_WWW_PROFILING
react-dom-server.browser.development.js 0.0% -0.0% 155 KB 155 KB 39.38 KB 39.38 KB UMD_DEV
react-dom-unstable-fizz.node.production.min.js 0.0% -0.5% 1.16 KB 1.16 KB 660 B 657 B NODE_PROD
react-dom.production.min.js -0.0% -0.0% 119.55 KB 119.52 KB 38.25 KB 38.24 KB UMD_PROD
react-dom.profiling.min.js -0.0% -0.0% 123.27 KB 123.26 KB 39.48 KB 39.47 KB UMD_PROFILING
ReactDOMTesting-dev.js -0.0% -0.0% 956.46 KB 956.1 KB 212.77 KB 212.7 KB FB_WWW_DEV
react-dom.development.js -0.1% -0.0% 862.22 KB 861.78 KB 196.31 KB 196.23 KB NODE_DEV
ReactDOMTesting-prod.js 0.0% 0.0% 405.02 KB 405.08 KB 73.45 KB 73.46 KB FB_WWW_PROD
react-dom-server.browser.development.js 0.0% -0.0% 145.85 KB 145.85 KB 38.63 KB 38.63 KB NODE_DEV
ReactDOM-dev.js -0.0% -0.0% 1007.43 KB 1007.07 KB 223.11 KB 223.05 KB FB_WWW_DEV
ReactDOMServer-dev.js 0.0% -0.0% 157.98 KB 157.98 KB 39.92 KB 39.92 KB FB_WWW_DEV
ReactDOM-prod.js 0.0% 0.0% 421.47 KB 421.54 KB 75.8 KB 75.83 KB FB_WWW_PROD
react-dom-test-utils.development.js 0.0% -0.0% 69.97 KB 69.97 KB 19.6 KB 19.6 KB NODE_DEV
ReactDOMServer-prod.js 0.0% -0.0% 53.29 KB 53.29 KB 12.84 KB 12.84 KB FB_WWW_PROD
ReactDOM-profiling.js 0.0% 0.0% 432.35 KB 432.44 KB 77.69 KB 77.72 KB FB_WWW_PROFILING
react-dom-test-utils.production.min.js 0.0% -0.0% 13.09 KB 13.09 KB 4.8 KB 4.8 KB NODE_PROD
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 56.1 KB 56.1 KB 13.84 KB 13.84 KB UMD_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.2% 1 KB 1 KB 610 B 609 B NODE_PROD
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.1% 9.98 KB 9.98 KB 3.36 KB 3.35 KB UMD_PROD
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 53.2 KB 53.2 KB 13.64 KB 13.64 KB NODE_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.1% 9.73 KB 9.73 KB 3.25 KB 3.25 KB NODE_PROD

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler.development.js -0.1% -0.1% 576.34 KB 575.91 KB 121.91 KB 121.79 KB NODE_DEV
react-reconciler-reflection.development.js 0.0% -0.0% 16.22 KB 16.22 KB 4.91 KB 4.91 KB NODE_DEV
react-reconciler.production.min.js -0.0% -0.1% 77.12 KB 77.1 KB 22.86 KB 22.85 KB NODE_PROD
react-reconciler-reflection.production.min.js 0.0% -0.1% 2.57 KB 2.57 KB 1.08 KB 1.08 KB NODE_PROD

Size changes (stable)

Generated by 🚫 dangerJS against 0c43f3e

@sebmarkbage
Copy link
Collaborator Author

Looks like fast-refresh is mutating the hook object. :(

if (
injectedHook &&
typeof injectedHook.onScheduleFiberRoot === 'function'
) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could sent pointers to e.g. onScheduleFiberRoot directly so we wouldn't have to do the property access

if (typeof onScheduleFiberRoot === 'function') {
  onScheduleFiberRoot(rendererID, root, chilren);
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Seb is saying that property gets mutated by Fast Refresh. (I don't actually remember if it does but I guess?)

Copy link
Collaborator

@gaearon gaearon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

@gaearon
Copy link
Collaborator

gaearon commented Apr 1, 2020

So, landing this?

Nested closures are tricky. They're not super efficient and when they share
scope between multiple closures they're hard for a compiler to optimize.
It's also unclear how many versions will be created.

By hoisting things out an just make it simple calls the compiler can do
a much better job.
@sebmarkbage sebmarkbage merged commit b014e2d into facebook:master Apr 9, 2020
@pgn-vole
Copy link

pgn-vole commented May 26, 2020

Thanks for this change. FYI - It is also fixing a bug with React Fast refresh which happen when hook.onScheduleFiberRoot is defined after React code is excuted.
In this setup, Fast Refresh will not work properly because it didn't manage to register a root because React didn't called its callback.

In our setup, we have 2 bundles - one contains React (loaded first) and a second one containing the Fast Refresh runtime (+ app code). Since Fast refresh runtime is executed after React it wasn't working fully.

Beside this little quirk Fast Refresh is really great and reliable:+1:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants