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

[Partial Hydration] Add "hydrationOptions" behind the enableSuspenseCallback flag #16434

Merged
merged 1 commit into from
Aug 19, 2019

Conversation

sebmarkbage
Copy link
Collaborator

@sebmarkbage sebmarkbage commented Aug 17, 2019

This gets invoked when a boundary is either hydrated or if it is deleted because its props/context updated before getting hydrated or a parent got deleted before it mounted.

If there are nested boundaries in the tree that we haven't gotten to yet and the parent gets deleted, then no callback is fired. Only the top one.

If we have a hydration error that causes us to delete the parent node, then there also isn't a callback. That could however be a different callback we could add.

@sizebot
Copy link

sizebot commented Aug 17, 2019

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

Details of bundled changes.

Comparing: 6f86294...16c34b7

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js +0.3% +0.1% 648.01 KB 649.76 KB 141.61 KB 141.82 KB UMD_DEV
react-art.production.min.js 🔺+0.1% 🔺+0.1% 101.77 KB 101.82 KB 31.09 KB 31.13 KB UMD_PROD
react-art.development.js +0.3% +0.2% 578.87 KB 580.63 KB 124.22 KB 124.43 KB NODE_DEV
react-art.production.min.js 🔺+0.1% 🔺+0.2% 66.77 KB 66.83 KB 20.33 KB 20.37 KB NODE_PROD
ReactART-dev.js +0.3% +0.1% 594.29 KB 595.92 KB 124.08 KB 124.2 KB FB_WWW_DEV
ReactART-prod.js 🔺+0.7% 🔺+0.7% 219.86 KB 221.41 KB 37.46 KB 37.73 KB FB_WWW_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-prod.js 🔺+0.1% 🔺+0.1% 269.2 KB 269.59 KB 46.15 KB 46.21 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js +0.1% +0.1% 277.66 KB 278.05 KB 47.68 KB 47.75 KB RN_OSS_PROFILING
ReactFabric-prod.js 0.0% 🔺+0.1% 261.42 KB 261.46 KB 44.89 KB 44.91 KB RN_OSS_PROD
ReactFabric-profiling.js 0.0% 0.0% 270.08 KB 270.12 KB 46.41 KB 46.42 KB RN_OSS_PROFILING
ReactFabric-dev.js +0.2% +0.1% 736.59 KB 738.21 KB 155.94 KB 156.04 KB RN_FB_DEV
ReactFabric-prod.js 0.0% 🔺+0.1% 261.42 KB 261.46 KB 44.9 KB 44.93 KB RN_FB_PROD
ReactNativeRenderer-dev.js +0.2% +0.1% 726.95 KB 728.58 KB 154.36 KB 154.46 KB RN_OSS_DEV
ReactFabric-profiling.js 0.0% 0.0% 270.08 KB 270.12 KB 46.42 KB 46.43 KB RN_FB_PROFILING
ReactNativeRenderer-dev.js +0.2% +0.1% 727.11 KB 728.74 KB 154.43 KB 154.54 KB RN_FB_DEV
ReactNativeRenderer-prod.js 🔺+0.1% 🔺+0.1% 269.2 KB 269.59 KB 46.16 KB 46.22 KB RN_FB_PROD
ReactNativeRenderer-profiling.js +0.1% +0.1% 277.65 KB 278.04 KB 47.69 KB 47.76 KB RN_FB_PROFILING
ReactFabric-dev.js +0.2% +0.1% 736.42 KB 738.04 KB 155.87 KB 155.97 KB RN_OSS_DEV

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.profiling.min.js +0.1% +0.1% 115.03 KB 115.18 KB 36.29 KB 36.31 KB NODE_PROFILING
react-dom-server.browser.development.js +0.1% +0.1% 140.04 KB 140.13 KB 36.79 KB 36.83 KB UMD_DEV
ReactDOM-dev.js +0.2% +0.1% 934.45 KB 936.38 KB 206.83 KB 207 KB FB_WWW_DEV
react-dom-server.browser.production.min.js 0.0% -0.0% 19.68 KB 19.68 KB 7.32 KB 7.32 KB UMD_PROD
react-dom-test-utils.development.js +0.2% +0.3% 57.1 KB 57.19 KB 15.69 KB 15.73 KB UMD_DEV
react-dom-test-utils.development.js +0.2% +0.3% 55.37 KB 55.47 KB 15.36 KB 15.41 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% -0.0% 10.98 KB 10.98 KB 4.08 KB 4.08 KB NODE_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.2% 1.04 KB 1.04 KB 634 B 633 B NODE_PROD
react-dom.development.js +0.2% +0.1% 909.96 KB 911.95 KB 206.58 KB 206.82 KB UMD_DEV
react-dom.production.min.js 🔺+0.1% 🔺+0.2% 111.43 KB 111.58 KB 35.91 KB 35.99 KB UMD_PROD
react-dom.profiling.min.js +0.1% +0.1% 114.83 KB 114.98 KB 36.94 KB 36.98 KB UMD_PROFILING
react-dom.development.js +0.2% +0.1% 904.25 KB 906.24 KB 204.98 KB 205.24 KB NODE_DEV
react-dom-server.node.development.js +0.1% +0.1% 137.19 KB 137.28 KB 36.07 KB 36.12 KB NODE_DEV
react-dom.production.min.js 🔺+0.1% 🔺+0.1% 111.4 KB 111.54 KB 35.35 KB 35.38 KB NODE_PROD
ReactDOM-prod.js 🔺+0.4% 🔺+0.4% 370.96 KB 372.61 KB 68.07 KB 68.35 KB FB_WWW_PROD
ReactDOM-profiling.js +0.5% +0.4% 376.04 KB 377.8 KB 69.12 KB 69.41 KB FB_WWW_PROFILING
react-dom-server.browser.development.js +0.1% +0.1% 136.17 KB 136.27 KB 35.85 KB 35.89 KB NODE_DEV
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 60.71 KB 60.71 KB 15.85 KB 15.85 KB UMD_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.0% 10.75 KB 10.75 KB 3.68 KB 3.68 KB UMD_PROD
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 60.39 KB 60.39 KB 15.72 KB 15.72 KB NODE_DEV

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactTestRenderer-dev.js +0.3% +0.1% 605.31 KB 606.95 KB 126.48 KB 126.6 KB FB_WWW_DEV
react-test-renderer.development.js +0.3% +0.1% 592.08 KB 593.74 KB 126.96 KB 127.13 KB UMD_DEV
react-test-renderer.production.min.js 🔺+0.1% 🔺+0.2% 68.7 KB 68.77 KB 21.1 KB 21.15 KB UMD_PROD
react-test-renderer.development.js +0.3% +0.1% 587.61 KB 589.27 KB 125.82 KB 125.99 KB NODE_DEV
react-test-renderer.production.min.js 🔺+0.1% 🔺+0.2% 68.4 KB 68.46 KB 20.83 KB 20.86 KB NODE_PROD

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler.development.js +0.3% +0.2% 577.49 KB 579.25 KB 122.89 KB 123.1 KB NODE_DEV
react-reconciler.production.min.js 🔺+0.1% 🔺+0.3% 68.74 KB 68.8 KB 20.35 KB 20.41 KB NODE_PROD
react-reconciler-reflection.development.js +0.5% +0.7% 19.09 KB 19.19 KB 6.24 KB 6.28 KB NODE_DEV
react-reconciler-reflection.production.min.js 0.0% 🔺+0.1% 2.58 KB 2.58 KB 1.13 KB 1.13 KB NODE_PROD
react-reconciler-persistent.development.js +0.3% +0.1% 574.63 KB 576.28 KB 121.67 KB 121.84 KB NODE_DEV
react-reconciler-persistent.production.min.js 🔺+0.1% 🔺+0.3% 68.75 KB 68.81 KB 20.36 KB 20.42 KB NODE_PROD

Generated by 🚫 dangerJS

This gets invoked when a boundary is either hydrated or if it is deleted
because it updated or got deleted before it mounted.
@@ -644,7 +649,8 @@ function hideOrUnhideAllChildren(finishedWork, isHidden) {
}
} else if (
node.tag === SuspenseComponent &&
node.memoizedState !== null
node.memoizedState !== null &&
node.memoizedState.dehydrated === null
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this about? I don't see you setting it in this PR.

Is this a behavior change? Wasn't the feature logging-only? Or was this always null 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.

This probably should've been in #16346 but it was not observable because we weren't scheduling an Update effect in this scenario. Now that we do, we need to differentiate what purpose the Update effect has.

const hydrationCallbacks = finishedRoot.hydrationCallbacks;
if (hydrationCallbacks !== null) {
const onDeleted = hydrationCallbacks.onDeleted;
if (onDeleted) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

!== null?

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 is an optional property. In some other cases we check typeof ... === 'function' when it's a prop, but in some cases we check truthiness. Not sure which one to be consistent with so I went with the one that takes fewer bytes.

@@ -859,6 +859,10 @@ function completeWork(
if ((workInProgress.effectTag & DidCapture) === NoEffect) {
// This boundary did not suspend so it's now hydrated and unsuspended.
workInProgress.memoizedState = null;
if (enableSuspenseCallback) {
// Notify the callback.
workInProgress.effectTag |= Update;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems a bit worrying to have a generic effect tag like this behind a flag since this may significantly fork execution path wherever we check for Update.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yea, that's a fair concern. I'm not very confident that this will be a lasting API form though so wouldn't want to do a big refactor yet nor should be pay the cost if it's not needed.

The event replaying might need this flag too and that might move out to a shared path sooner.

@@ -91,6 +100,7 @@ type ProfilingOnlyFiberRootProperties = {|
export type FiberRoot = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

While we're here, should this have been exact?

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 don't think Flow supported the spreading as exact but arguably we shouldn't do the spreading neither. We don't for Fiber.

@sebmarkbage sebmarkbage merged commit c80678c into facebook:master Aug 19, 2019
NMinhNguyen referenced this pull request in enzymejs/react-shallow-renderer Jan 29, 2020
This gets invoked when a boundary is either hydrated or if it is deleted
because it updated or got deleted before it mounted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants