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

Add tail="hidden" option to SuspenseList #16024

Merged
merged 5 commits into from
Jul 12, 2019

Conversation

sebmarkbage
Copy link
Collaborator

@sebmarkbage sebmarkbage commented Jul 1, 2019

Builds on top of #16007.

This is similar to tail="collapsed" except it hides all rows in the tail. The added complexity here is that sometimes we only know that we've hit the tail after we've already rendered this row. So we need undo the effects added by rendering the row.

Additionally, by not committing the boundary, there's nothing to retry. So we need to transfer the promise set to the list so that we get a retry if the only thing to ping was in the tail.

@sizebot
Copy link

sizebot commented Jul 1, 2019

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

Details of bundled changes.

Comparing: 29b4559...6ec55cb

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js +0.1% 0.0% 628.14 KB 628.88 KB 137.93 KB 137.95 KB UMD_DEV
react-art.production.min.js 0.0% 🔺+0.1% 102.2 KB 102.22 KB 31.27 KB 31.28 KB UMD_PROD
react-art.development.js +0.1% 0.0% 559 KB 559.74 KB 120.55 KB 120.57 KB NODE_DEV
react-art.production.min.js 0.0% -0.0% 67.25 KB 67.27 KB 20.61 KB 20.6 KB NODE_PROD
ReactART-dev.js +0.1% -0.0% 572.1 KB 572.76 KB 120.15 KB 120.15 KB FB_WWW_DEV
ReactART-prod.js -0.1% -0.1% 218.6 KB 218.39 KB 37.11 KB 37.07 KB FB_WWW_PROD

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.profiling.min.js 0.0% -0.0% 114.94 KB 114.97 KB 36.25 KB 36.25 KB NODE_PROFILING
react-dom-server.browser.development.js 0.0% -0.0% 135.74 KB 135.74 KB 35.81 KB 35.81 KB UMD_DEV
ReactDOM-dev.js +0.1% -0.0% 914.66 KB 915.32 KB 203.45 KB 203.43 KB FB_WWW_DEV
react-dom-server.browser.production.min.js 0.0% -0.0% 19.34 KB 19.34 KB 7.23 KB 7.23 KB UMD_PROD
react-dom-test-utils.development.js 0.0% -0.0% 57.96 KB 57.96 KB 15.91 KB 15.91 KB UMD_DEV
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 3.78 KB 3.78 KB 1.52 KB 1.52 KB UMD_DEV
react-dom-test-utils.production.min.js 0.0% -0.1% 10.95 KB 10.95 KB 4.01 KB 4 KB UMD_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.3% 1.21 KB 1.21 KB 707 B 705 B UMD_PROD
react-dom-test-utils.development.js 0.0% -0.0% 56.22 KB 56.22 KB 15.59 KB 15.59 KB NODE_DEV
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 3.61 KB 3.61 KB 1.48 KB 1.47 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% -0.1% 10.71 KB 10.71 KB 3.95 KB 3.94 KB NODE_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.3% 1.05 KB 1.05 KB 638 B 636 B NODE_PROD
react-dom.development.js +0.1% 0.0% 891.93 KB 892.67 KB 203.05 KB 203.05 KB UMD_DEV
react-dom.production.min.js 0.0% -0.1% 111.21 KB 111.25 KB 35.81 KB 35.79 KB UMD_PROD
react-dom.profiling.min.js 0.0% 0.0% 114.66 KB 114.69 KB 36.85 KB 36.85 KB UMD_PROFILING
react-dom.development.js +0.1% 0.0% 886.21 KB 886.96 KB 201.54 KB 201.55 KB NODE_DEV
react-dom-server.node.development.js 0.0% -0.0% 133.8 KB 133.8 KB 35.43 KB 35.43 KB NODE_DEV
react-dom.production.min.js 0.0% -0.1% 111.29 KB 111.32 KB 35.33 KB 35.3 KB NODE_PROD
react-dom-server.node.production.min.js 0.0% -0.0% 20.11 KB 20.11 KB 7.54 KB 7.54 KB NODE_PROD
ReactDOM-prod.js 0.0% -0.0% 371.01 KB 371.14 KB 68.03 KB 68.01 KB FB_WWW_PROD
ReactDOM-profiling.js +0.1% -0.0% 377.34 KB 377.58 KB 69.37 KB 69.37 KB FB_WWW_PROFILING
react-dom-server.browser.development.js 0.0% -0.0% 131.88 KB 131.88 KB 34.89 KB 34.89 KB NODE_DEV
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 60.76 KB 60.76 KB 15.85 KB 15.85 KB UMD_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.1% 10.74 KB 10.74 KB 3.68 KB 3.68 KB UMD_PROD
ReactDOMServer-dev.js 0.0% -0.0% 134.27 KB 134.27 KB 34.45 KB 34.45 KB FB_WWW_DEV
ReactDOMServer-prod.js 0.0% -0.0% 46.67 KB 46.67 KB 10.74 KB 10.74 KB FB_WWW_PROD
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 60.43 KB 60.43 KB 15.72 KB 15.72 KB NODE_DEV
react-dom-unstable-fizz.node.development.js 0.0% -0.1% 3.85 KB 3.85 KB 1.5 KB 1.5 KB NODE_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.1% 10.48 KB 10.48 KB 3.58 KB 3.58 KB NODE_PROD
react-dom-unstable-fizz.node.production.min.js 0.0% -0.1% 1.1 KB 1.1 KB 668 B 667 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% 272.23 KB 272.1 KB 46.78 KB 46.74 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js +0.3% +0.1% 279.66 KB 280.6 KB 48.3 KB 48.34 KB RN_OSS_PROFILING
ReactFabric-prod.js -0.1% -0.2% 266.42 KB 266.2 KB 45.95 KB 45.87 KB RN_OSS_PROD
ReactFabric-profiling.js +0.2% 0.0% 274.43 KB 274.91 KB 47.36 KB 47.37 KB RN_OSS_PROFILING
ReactFabric-dev.js +0.1% 0.0% 720.66 KB 721.32 KB 153.42 KB 153.43 KB RN_FB_DEV
ReactFabric-prod.js -0.1% -0.2% 266.42 KB 266.21 KB 45.96 KB 45.88 KB RN_FB_PROD
ReactNativeRenderer-dev.js +0.1% 0.0% 707.09 KB 707.75 KB 150.8 KB 150.82 KB RN_OSS_DEV
ReactFabric-profiling.js +0.2% 0.0% 274.43 KB 274.91 KB 47.37 KB 47.38 KB RN_FB_PROFILING
ReactNativeRenderer-dev.js +0.1% 0.0% 707.19 KB 707.85 KB 150.86 KB 150.87 KB RN_FB_DEV
ReactNativeRenderer-prod.js -0.0% -0.1% 272.23 KB 272.1 KB 46.79 KB 46.75 KB RN_FB_PROD
ReactNativeRenderer-profiling.js +0.3% +0.1% 279.65 KB 280.59 KB 48.3 KB 48.35 KB RN_FB_PROFILING
ReactFabric-dev.js +0.1% 0.0% 720.56 KB 721.22 KB 153.38 KB 153.38 KB RN_OSS_DEV

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactTestRenderer-dev.js +0.1% -0.0% 582.02 KB 582.68 KB 122.48 KB 122.48 KB FB_WWW_DEV
react-test-renderer-shallow.development.js 0.0% -0.0% 41.46 KB 41.46 KB 10.79 KB 10.78 KB UMD_DEV
react-test-renderer-shallow.production.min.js 0.0% -0.1% 11.66 KB 11.66 KB 3.56 KB 3.56 KB UMD_PROD
react-test-renderer-shallow.development.js 0.0% -0.0% 35.6 KB 35.6 KB 9.41 KB 9.41 KB NODE_DEV
react-test-renderer-shallow.production.min.js 0.0% -0.1% 11.8 KB 11.8 KB 3.68 KB 3.68 KB NODE_PROD
react-test-renderer.development.js +0.1% 0.0% 571.35 KB 572.09 KB 123.24 KB 123.25 KB UMD_DEV
react-test-renderer.production.min.js 0.0% -0.0% 68.6 KB 68.63 KB 21.06 KB 21.06 KB UMD_PROD
react-test-renderer.development.js +0.1% 0.0% 566.89 KB 567.63 KB 122.09 KB 122.11 KB NODE_DEV
react-test-renderer.production.min.js 0.0% -0.1% 68.32 KB 68.33 KB 20.82 KB 20.81 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.0% 557.2 KB 557.95 KB 119.09 KB 119.1 KB NODE_DEV
react-reconciler.production.min.js 0.0% -0.1% 68.5 KB 68.52 KB 20.42 KB 20.39 KB NODE_PROD
react-reconciler-reflection.development.js 0.0% -0.0% 18.66 KB 18.66 KB 6.03 KB 6.03 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.1% 0.0% 554.79 KB 555.53 KB 118.02 KB 118.04 KB NODE_DEV
react-reconciler-persistent.production.min.js 0.0% -0.1% 68.51 KB 68.53 KB 20.42 KB 20.39 KB NODE_PROD

Generated by 🚫 dangerJS

@sebmarkbage
Copy link
Collaborator Author

sebmarkbage commented Jul 2, 2019

SSR is pretty tricky with this approach, since we won't have DOM nodes for all the items in the list during reconciliation. If we assume that we have the same number of items in the list and that we suspend at at least the same places as the server, then at least the collapsed mode works out. Because we'll at most render the last tail item which will be in fallback state on the server and get replaced on the client. However, with "hidden" mode, we don't know that we've hit the end of the list yet. We need to render it first and when we try to do that, we get a hydration error because that node was deleted.

If they were actually just hidden we could potentially start hydrating them.

@sebmarkbage sebmarkbage force-pushed the suspensehidden branch 2 times, most recently from 4c8d987 to 8039935 Compare July 12, 2019 04:34
@sebmarkbage sebmarkbage changed the title [WIP] Add tail="hidden" option to SuspenseList Add tail="hidden" option to SuspenseList Jul 12, 2019
This lets us reuse the found fallback so we can transfer the update queue
from it.
This function exists to optimize the case where all the boundaries in the
head are already suspended. In that case there's no need to do a second
rerender pass. However, in that case, we're not really going to show much
new content on the screen anyway.

So I'm not sure it's worth keeping this special case around.

scan every row
@sebmarkbage
Copy link
Collaborator Author

I think this is ready for review and landing now.

I ended up needing to do a lot of factoring to make it nicer and found a number of bugs along the way.

Particularly, to minimize file size I ended up removing one optimization which causes extra rerenders. 6ec55cb I'm not sure this is the right call but maybe with resuming this won't matter much.

I'll address the SSR case in a follow up.

hasSuspendedChildrenAndNewContent(workInProgress, renderedTail);
let newThennables = suspended.updateQueue;
if (newThennables !== null) {
workInProgress.updateQueue = newThennables;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this approach something we'll want to rethink later? By always attaching thenables to the SuspenseList instead of the inner boundary, perhaps.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could possibly do that in throwException, yea.

@sebmarkbage sebmarkbage merged commit fcff9c5 into facebook:master Jul 12, 2019
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.

None yet

4 participants