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

Refactor Lazy Components to use teh Suspense (and wrap Blocks in Lazy) #18362

Merged
merged 3 commits into from
Mar 23, 2020

Conversation

sebmarkbage
Copy link
Collaborator

@sebmarkbage sebmarkbage commented Mar 21, 2020

I wasn't happy with my approach in #18220

Exposing the status stuff leaks a lot of complexity downstream. It avoids taking on a virtual dispatch but also means that other code (like Flight and Blocks) can't take advantage of what Lazy already does.

Using the suspense protocol is actually really nice in terms of code size and complexity. The principle is simple:

  • Expose a function to call to get the value. This lazily does any work it needs to do.
  • If it can't, throw an error or promise.

The lazy component type can now be used to implement all kinds of lazy behavior. So I also use it to implement lazy Blocks.

@sebmarkbage sebmarkbage requested review from gaearon and acdlite March 21, 2020 18:08
@facebook-github-bot facebook-github-bot added React Core Team Opened by a member of the React Core Team CLA Signed labels Mar 21, 2020
let payload = lazyComponent._payload;
let init = lazyComponent._init;
try {
return getComponentName(init(payload));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Getting the component name can now have side-effects, causing data to load.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Mar 21, 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 8a6c32b:

Sandbox Source
empty-shadow-lzy7q Configuration

@sizebot
Copy link

sizebot commented Mar 21, 2020

Details of bundled changes.

Comparing: 31a9e39...8a6c32b

react

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react.development.js +1.4% +1.3% 103.49 KB 104.92 KB 25.17 KB 25.5 KB UMD_DEV
react.production.min.js 🔺+2.7% 🔺+2.4% 12.34 KB 12.67 KB 4.79 KB 4.91 KB UMD_PROD
JSXRuntime-dev.js -0.6% -0.8% 29.41 KB 29.22 KB 8.64 KB 8.57 KB FB_WWW_DEV
react-jsx-dev-runtime.development.js -0.7% -0.8% 26.32 KB 26.14 KB 8.08 KB 8.02 KB NODE_DEV
JSXDEVRuntime-dev.js -0.6% -0.8% 28.82 KB 28.64 KB 8.46 KB 8.4 KB FB_WWW_DEV
react-jsx-runtime.development.js -0.7% -0.8% 26.91 KB 26.73 KB 8.26 KB 8.2 KB NODE_DEV
react.profiling.min.js +2.1% +2.0% 15.88 KB 16.21 KB 5.89 KB 6.01 KB UMD_PROFILING
react.development.js +2.1% +1.9% 65.12 KB 66.46 KB 17.44 KB 17.78 KB NODE_DEV
react.production.min.js 🔺+4.6% 🔺+3.8% 7.27 KB 7.61 KB 2.88 KB 2.99 KB NODE_PROD
React-dev.js +1.7% +1.9% 88.69 KB 90.16 KB 21.52 KB 21.92 KB FB_WWW_DEV
React-prod.js 🔺+4.2% 🔺+3.8% 17.92 KB 18.68 KB 4.6 KB 4.77 KB FB_WWW_PROD
React-profiling.js +4.2% +3.8% 17.92 KB 18.68 KB 4.6 KB 4.77 KB FB_WWW_PROFILING

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom-server.browser.development.js -1.5% -1.4% 136.74 KB 134.74 KB 34.96 KB 34.47 KB UMD_DEV
react-dom-server.browser.production.min.js -1.3% -1.2% 20.43 KB 20.17 KB 7.49 KB 7.4 KB UMD_PROD
react-dom.profiling.min.js -0.3% -0.2% 126.66 KB 126.24 KB 39.6 KB 39.52 KB NODE_PROFILING
ReactDOM-dev.js -0.2% -0.2% 940.1 KB 937.88 KB 209.27 KB 208.79 KB FB_WWW_DEV
ReactDOM-prod.js -0.4% -0.4% 385.13 KB 383.61 KB 70.06 KB 69.79 KB FB_WWW_PROD
ReactDOM-profiling.js -0.4% -0.4% 402.72 KB 401.2 KB 73.09 KB 72.83 KB FB_WWW_PROFILING
react-dom-test-utils.development.js 0.0% -0.0% 59.32 KB 59.32 KB 15.69 KB 15.69 KB UMD_DEV
ReactDOMTesting-dev.js -0.2% -0.2% 893.86 KB 891.63 KB 199.71 KB 199.26 KB FB_WWW_DEV
ReactDOMTesting-prod.js -0.3% -0.3% 378.04 KB 376.8 KB 69.12 KB 68.88 KB FB_WWW_PROD
react-dom-test-utils.development.js 0.0% 0.0% 54.78 KB 54.78 KB 15.08 KB 15.08 KB NODE_DEV
ReactDOMTesting-profiling.js -0.3% -0.3% 378.04 KB 376.8 KB 69.12 KB 68.88 KB FB_WWW_PROFILING
react-dom-server.node.development.js -1.5% -1.4% 130.95 KB 129.05 KB 34.79 KB 34.3 KB NODE_DEV
react-dom-server.node.production.min.js -1.3% -1.0% 20.75 KB 20.49 KB 7.6 KB 7.52 KB NODE_PROD
react-dom-server.browser.development.js -1.5% -1.4% 129.73 KB 127.83 KB 34.53 KB 34.05 KB NODE_DEV
react-dom-server.browser.production.min.js -1.3% -1.0% 20.34 KB 20.08 KB 7.45 KB 7.38 KB NODE_PROD
react-dom.development.js -0.2% -0.3% 935.3 KB 933.17 KB 204.25 KB 203.73 KB UMD_DEV
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 57.71 KB 57.71 KB 14.36 KB 14.36 KB UMD_DEV
react-dom.production.min.js -0.3% -0.3% 122.53 KB 122.11 KB 39.15 KB 39.04 KB UMD_PROD
ReactDOMForked-dev.js -0.2% -0.2% 940.1 KB 937.88 KB 209.27 KB 208.79 KB FB_WWW_DEV
ReactDOMServer-dev.js -1.5% -1.5% 137.51 KB 135.47 KB 35.13 KB 34.6 KB FB_WWW_DEV
react-dom.profiling.min.js -0.3% -0.3% 126.36 KB 125.94 KB 40.4 KB 40.28 KB UMD_PROFILING
ReactDOMForked-prod.js -0.4% -0.4% 385.13 KB 383.61 KB 70.06 KB 69.79 KB FB_WWW_PROD
ReactDOMServer-prod.js -1.7% -1.8% 46.7 KB 45.91 KB 10.87 KB 10.67 KB FB_WWW_PROD
react-dom.development.js -0.2% -0.2% 890.4 KB 888.37 KB 201.7 KB 201.24 KB NODE_DEV
ReactDOMForked-profiling.js -0.4% -0.4% 402.72 KB 401.2 KB 73.09 KB 72.83 KB FB_WWW_PROFILING
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 54.72 KB 54.72 KB 14.14 KB 14.14 KB NODE_DEV
react-dom.production.min.js -0.3% -0.2% 122.68 KB 122.26 KB 38.33 KB 38.24 KB NODE_PROD
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.0% 10.05 KB 10.05 KB 3.38 KB 3.38 KB NODE_PROD

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactART-dev.js -0.4% -0.4% 570.86 KB 568.64 KB 119.5 KB 119.08 KB FB_WWW_DEV
react-art.development.js -0.3% -0.3% 653.99 KB 651.85 KB 137.03 KB 136.61 KB UMD_DEV
react-art.production.min.js -0.4% -0.4% 109.04 KB 108.63 KB 33.05 KB 32.93 KB UMD_PROD
react-art.development.js -0.4% -0.3% 557.31 KB 555.27 KB 119.38 KB 118.97 KB NODE_DEV
react-art.production.min.js -0.6% -0.5% 74.03 KB 73.61 KB 22.19 KB 22.09 KB NODE_PROD
ReactART-prod.js -0.6% -0.6% 232.92 KB 231.46 KB 39.75 KB 39.51 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.3% -0.3% 570.52 KB 569.08 KB 118.55 KB 118.18 KB UMD_DEV
react-test-renderer.production.min.js -0.3% -0.3% 73.33 KB 73.11 KB 22.35 KB 22.29 KB UMD_PROD
react-test-renderer.development.js -0.3% -0.3% 543.77 KB 542.39 KB 117.14 KB 116.77 KB NODE_DEV
react-test-renderer.production.min.js -0.3% -0.3% 73.15 KB 72.93 KB 22.03 KB 21.98 KB NODE_PROD
ReactTestRenderer-dev.js -0.3% -0.3% 571.21 KB 569.69 KB 120.41 KB 120.01 KB FB_WWW_DEV
react-test-renderer-shallow.development.js 0.0% -0.0% 38.4 KB 38.4 KB 9.3 KB 9.3 KB UMD_DEV
react-test-renderer-shallow.production.min.js 0.0% -0.0% 12.92 KB 12.92 KB 3.94 KB 3.94 KB UMD_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactFabric-dev.js -0.2% -0.3% 635.77 KB 634.25 KB 136.75 KB 136.29 KB RN_FB_DEV
ReactFabric-prod.js -0.2% -0.3% 259.48 KB 258.88 KB 45.02 KB 44.88 KB RN_FB_PROD
ReactNativeRenderer-dev.js -0.2% -0.3% 651.19 KB 649.67 KB 140.77 KB 140.37 KB RN_OSS_DEV
ReactFabric-profiling.js -0.2% -0.3% 271.27 KB 270.67 KB 47.26 KB 47.13 KB RN_FB_PROFILING
ReactNativeRenderer-prod.js -0.2% -0.3% 267.34 KB 266.75 KB 46.46 KB 46.33 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js -0.2% -0.3% 279.14 KB 278.54 KB 48.72 KB 48.59 KB RN_OSS_PROFILING
ReactNativeRenderer-dev.js -0.2% -0.3% 653.9 KB 652.38 KB 141.12 KB 140.71 KB RN_FB_DEV
ReactNativeRenderer-prod.js -0.2% -0.3% 267.49 KB 266.89 KB 46.49 KB 46.35 KB RN_FB_PROD
ReactNativeRenderer-profiling.js -0.2% -0.3% 279.28 KB 278.68 KB 48.74 KB 48.61 KB RN_FB_PROFILING
ReactFabric-dev.js -0.2% -0.3% 633.05 KB 631.53 KB 136.41 KB 135.96 KB RN_OSS_DEV
ReactFabric-prod.js -0.2% -0.3% 259.33 KB 258.73 KB 44.98 KB 44.85 KB RN_OSS_PROD
ReactFabric-profiling.js -0.2% -0.3% 271.12 KB 270.53 KB 47.23 KB 47.1 KB RN_OSS_PROFILING

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler.development.js -0.3% -0.3% 597.68 KB 595.64 KB 125.71 KB 125.28 KB NODE_DEV
react-reconciler-reflection.development.js -1.1% -1.3% 15.74 KB 15.57 KB 4.79 KB 4.73 KB NODE_DEV
react-reconciler.production.min.js -0.5% -0.4% 79.27 KB 78.85 KB 23.32 KB 23.22 KB NODE_PROD

ReactDOM: size: -1.3%, gzip: -1.2%

React: size: 🔺+2.7%, gzip: 🔺+2.4%

Size changes (experimental)

Generated by 🚫 dangerJS against 8a6c32b

@sizebot
Copy link

sizebot commented Mar 21, 2020

Details of bundled changes.

Comparing: 31a9e39...8a6c32b

react

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react.development.js +1.3% +1.2% 100.29 KB 101.58 KB 24.59 KB 24.89 KB UMD_DEV
react.production.min.js 🔺+2.4% 🔺+2.2% 11.63 KB 11.91 KB 4.58 KB 4.68 KB UMD_PROD
JSXDEVRuntime-dev.js -0.6% -0.8% 28.82 KB 28.64 KB 8.47 KB 8.4 KB FB_WWW_DEV
react-jsx-runtime.development.js -0.7% -0.7% 26.89 KB 26.72 KB 8.25 KB 8.19 KB NODE_DEV
JSXRuntime-dev.js -0.6% -0.8% 29.41 KB 29.22 KB 8.64 KB 8.57 KB FB_WWW_DEV
react.profiling.min.js +1.8% +1.5% 15.17 KB 15.44 KB 5.7 KB 5.79 KB UMD_PROFILING
react.development.js +1.9% +2.1% 62.07 KB 63.28 KB 16.85 KB 17.2 KB NODE_DEV
react.production.min.js 🔺+4.2% 🔺+3.3% 6.53 KB 6.8 KB 2.66 KB 2.74 KB NODE_PROD
React-dev.js +1.6% +2.0% 89.37 KB 90.84 KB 21.65 KB 22.07 KB FB_WWW_DEV
React-prod.js 🔺+4.2% 🔺+3.8% 17.98 KB 18.74 KB 4.62 KB 4.79 KB FB_WWW_PROD
react-jsx-dev-runtime.development.js -0.7% -0.8% 26.31 KB 26.13 KB 8.08 KB 8.02 KB NODE_DEV
React-profiling.js +4.2% +3.8% 17.98 KB 18.74 KB 4.62 KB 4.79 KB FB_WWW_PROFILING

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.production.min.js -0.2% -0.2% 118.41 KB 118.19 KB 37.21 KB 37.13 KB NODE_PROD
ReactDOMTesting-profiling.js -0.3% -0.3% 391 KB 389.74 KB 71.17 KB 70.95 KB FB_WWW_PROFILING
react-dom-server.browser.production.min.js -1.3% -1.1% 19.88 KB 19.62 KB 7.37 KB 7.29 KB NODE_PROD
react-dom.profiling.min.js -0.2% -0.2% 122.26 KB 122.04 KB 38.41 KB 38.31 KB NODE_PROFILING
react-dom-test-utils.production.min.js 0.0% -0.0% 12.26 KB 12.26 KB 4.55 KB 4.55 KB UMD_PROD
react-dom-server.node.development.js -1.5% -1.4% 129.44 KB 127.53 KB 34.56 KB 34.09 KB NODE_DEV
react-dom-server.node.production.min.js -1.3% -1.1% 20.29 KB 20.03 KB 7.52 KB 7.44 KB NODE_PROD
ReactDOMForked-dev.js -0.2% -0.2% 985.95 KB 983.72 KB 219.23 KB 218.76 KB FB_WWW_DEV
ReactDOMForked-prod.js -0.3% -0.3% 411.13 KB 409.87 KB 74.66 KB 74.43 KB FB_WWW_PROD
react-dom.development.js -0.2% -0.2% 904.81 KB 903.37 KB 198.97 KB 198.51 KB UMD_DEV
ReactDOMForked-profiling.js -0.3% -0.3% 428.78 KB 427.51 KB 77.76 KB 77.54 KB FB_WWW_PROFILING
react-dom-server.browser.development.js -1.5% -1.4% 135.15 KB 133.15 KB 34.75 KB 34.27 KB UMD_DEV
react-dom.production.min.js -0.2% -0.2% 118.33 KB 118.11 KB 37.97 KB 37.88 KB UMD_PROD
react-dom-server.browser.production.min.js -1.3% -1.1% 19.97 KB 19.71 KB 7.42 KB 7.34 KB UMD_PROD
react-dom.profiling.min.js -0.2% -0.2% 122.04 KB 121.82 KB 39.18 KB 39.12 KB UMD_PROFILING
ReactDOMTesting-dev.js -0.2% -0.2% 920.61 KB 918.38 KB 205.43 KB 204.98 KB FB_WWW_DEV
react-dom.development.js -0.2% -0.2% 861.2 KB 859.82 KB 196.46 KB 196.08 KB NODE_DEV
ReactDOMTesting-prod.js -0.3% -0.3% 391 KB 389.74 KB 71.17 KB 70.95 KB FB_WWW_PROD
react-dom-server.browser.development.js -1.5% -1.4% 128.22 KB 126.32 KB 34.31 KB 33.84 KB NODE_DEV
ReactDOM-dev.js -0.2% -0.2% 985.95 KB 983.72 KB 219.23 KB 218.76 KB FB_WWW_DEV
ReactDOMServer-dev.js -1.5% -1.5% 138.36 KB 136.32 KB 35.27 KB 34.74 KB FB_WWW_DEV
ReactDOM-prod.js -0.3% -0.3% 411.13 KB 409.87 KB 74.66 KB 74.43 KB FB_WWW_PROD
ReactDOMServer-prod.js -1.7% -1.7% 47.41 KB 46.62 KB 11.05 KB 10.86 KB FB_WWW_PROD
ReactDOM-profiling.js -0.3% -0.3% 428.78 KB 427.51 KB 77.76 KB 77.54 KB FB_WWW_PROFILING
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 54.71 KB 54.71 KB 14.14 KB 14.13 KB NODE_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.0% 10.04 KB 10.04 KB 3.37 KB 3.37 KB NODE_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactFabric-dev.js -0.2% -0.3% 633.04 KB 631.52 KB 136.41 KB 135.96 KB RN_OSS_DEV
ReactNativeRenderer-dev.js -0.2% -0.3% 651.18 KB 649.66 KB 140.77 KB 140.36 KB RN_OSS_DEV
ReactNativeRenderer-prod.js -0.2% -0.3% 267.33 KB 266.73 KB 46.45 KB 46.32 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js -0.2% -0.3% 279.13 KB 278.53 KB 48.71 KB 48.58 KB RN_OSS_PROFILING
ReactFabric-prod.js -0.2% -0.3% 259.31 KB 258.71 KB 44.98 KB 44.84 KB RN_OSS_PROD
ReactFabric-profiling.js -0.2% -0.3% 271.11 KB 270.51 KB 47.22 KB 47.1 KB RN_OSS_PROFILING

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactART-dev.js -0.4% -0.3% 598.94 KB 596.71 KB 125.15 KB 124.75 KB FB_WWW_DEV
ReactART-prod.js -0.5% -0.5% 241.77 KB 240.5 KB 41.12 KB 40.9 KB FB_WWW_PROD
react-art.development.js -0.2% -0.3% 633.02 KB 631.58 KB 133.33 KB 132.95 KB UMD_DEV
react-art.production.min.js -0.2% -0.2% 106.29 KB 106.07 KB 32.27 KB 32.2 KB UMD_PROD
react-art.development.js -0.3% -0.3% 537.18 KB 535.8 KB 115.65 KB 115.28 KB NODE_DEV
react-art.production.min.js -0.3% -0.3% 71.33 KB 71.11 KB 21.47 KB 21.41 KB NODE_PROD

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactTestRenderer-dev.js -0.3% -0.3% 571.19 KB 569.67 KB 120.4 KB 120 KB FB_WWW_DEV
react-test-renderer-shallow.development.js 0.0% -0.0% 38.39 KB 38.39 KB 9.29 KB 9.29 KB UMD_DEV
react-test-renderer-shallow.production.min.js 0.0% -0.0% 12.91 KB 12.91 KB 3.94 KB 3.93 KB UMD_PROD
react-test-renderer.development.js -0.3% -0.3% 570.5 KB 569.05 KB 118.54 KB 118.16 KB UMD_DEV
react-test-renderer.production.min.js -0.3% -0.3% 73.31 KB 73.09 KB 22.33 KB 22.27 KB UMD_PROD
react-test-renderer.development.js -0.3% -0.3% 543.75 KB 542.37 KB 117.13 KB 116.76 KB NODE_DEV
react-test-renderer.production.min.js -0.3% -0.3% 73.13 KB 72.91 KB 22.02 KB 21.96 KB NODE_PROD

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler.development.js -0.2% -0.3% 575.22 KB 573.84 KB 121.46 KB 121.08 KB NODE_DEV
react-reconciler.production.min.js -0.3% -0.3% 76.18 KB 75.96 KB 22.58 KB 22.51 KB NODE_PROD
react-reconciler-reflection.development.js -1.1% -1.2% 15.73 KB 15.55 KB 4.79 KB 4.73 KB NODE_DEV

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

React: size: 🔺+2.4%, gzip: 🔺+2.2%

Size changes (stable)

Generated by 🚫 dangerJS against 8a6c32b

if (element.type.$$typeof === REACT_BLOCK_TYPE) {
let type = element.type;
if (type.$$typeof === REACT_LAZY_TYPE) {
type = resolveLazyType(type);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For updates, we attempt to initialize earlier to see if we can reconcile against the inner value. I only do this for Blocks right now to preserve backwards compatibility.

However, in non-legacy mode, we could reconcile against the resolved value of any type.

E.g. if I have two lazy components that resolve to the same thing, why shouldn't they reconcile against each other?

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.

nice

lazyComponent: LazyComponent<T, P>,
): LazyComponent<T, P> | T {
try {
// If we can, let's peak at the resulting type.
Copy link
Collaborator

Choose a reason for hiding this comment

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

try {
outerMemoType = init(payload);
} catch (x) {
outerMemoType = null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not just let it throw? If we got here, doesn't mean it's resolved anyway?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hm. I think you’re right. I think that we’d only get here if the init is not deterministic. I.e. if it resuspends. That’s a bug in the lazy code but could possibly happen as a bug in a “user provided lazy”.

That would be a prod changing behavior so probably best to keep this since it wouldn’t happen in prod (although the call wouldn’t happen neither).

@@ -879,7 +879,13 @@ describe('ReactLazy', () => {
},
);

expect(Scheduler).toFlushAndYield(['Started loading', 'Loading...']);
if (__DEV__) {
// Getting the name for the warning cause the loading to start early.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't know how I feel about this. Can you motivate?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we really should be refactoring the getComponentName stuff. One todo I have is to pass it a fiber because the type is not really enough. If we had the fiber we could read the .type off of that.

It’s called everywhere though so it’s some work to properly clean that up.

What annoys be a bit more is that we have that logic in prod. I suspect that’s what leads this PR to increase bundle size but just a little bit.

We probably should fork getComponentName and accompanying logic into specific DEV and prod versions for different use cases.

Regardless, I’m confident the fix is in the logging and not compromising the logic for lazy resolution.

@sebmarkbage sebmarkbage merged commit fd61f7e into facebook:master Mar 23, 2020
initializeBlockComponentType(element.type);
let type = element.type;
if (type.$$typeof === REACT_LAZY_TYPE) {
type = resolveLazyType(type);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This got lost when we dropped Blocks. The benefit of Blocks was that we only needed this check if the tag was Block but now we need to do it for everything.

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.

4 participants