Skip to content

[labs/react & labs/ssr-react] Coordinate props for server rendering and hydration - #3885

Merged
augustjk merged 13 commits into
mainfrom
ssr-react-props
May 16, 2023
Merged

augustjk merged 13 commits into
mainfrom
ssr-react-props

Conversation

@augustjk

@augustjk augustjk commented May 9, 2023

Copy link
Copy Markdown
Member

Fixes #3418

Recommend reviewing commit by commit.

  • labs/react now has a Node build. In Node mode, it'll check to see if React.createElement has been patched by checking its .name === 'litPatchedCreateElement', and if it has element properties that needs to be set, passes them in a special prop bag _$litProps$ which is a property that should not be minified.
  • labs/ssr-react during SSR will now set all React props it gets as attributes (breaking change), and only set as properties those that were provided via above special bag. It also adds defer-hydration attribute to host element if any properties were set this way.
  • labs/react wrapper on the client will remove defer-hydration attribute after setting props on the element in the wrapper component's componentDidMount lifecycle.

@augustjk
augustjk requested a review from kevinpschaaf as a code owner May 9, 2023 00:33
@changeset-bot

changeset-bot Bot commented May 9, 2023 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 088137a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@lit-labs/ssr-react Minor
@lit-labs/react Minor
@lit-labs/nextjs Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented May 9, 2023 •

Copy link
Copy Markdown
Contributor

📊 Tachometer Benchmark Results

Summary

nop-update

  • lit-html-kitchen-sink: unsure 🔍 -10% - +2% (-1.66ms - +0.42ms)
    this-change vs tip-of-tree

render

  • lit-element-list: 73.01ms - 77.38ms
  • lit-html-kitchen-sink: unsure 🔍 -5% - +9% (-1.29ms - +2.47ms)
    this-change vs tip-of-tree
  • lit-html-repeat: unsure 🔍 -4% - +8% (-0.47ms - +0.82ms)
    this-change vs tip-of-tree
  • lit-html-template-heavy: unsure 🔍 -3% - +3% (-1.70ms - +1.43ms)
    this-change vs tip-of-tree
  • reactive-element-list: unsure 🔍 -3% - +2% (-1.54ms - +1.16ms)
    this-change vs tip-of-tree

update

  • lit-element-list: 678.96ms - 687.01ms
  • lit-html-kitchen-sink: unsure 🔍 -2% - +6% (-1.78ms - +4.58ms)
    this-change vs tip-of-tree
  • lit-html-repeat: unsure 🔍 -4% - +3% (-10.27ms - +6.87ms)
    this-change vs tip-of-tree
  • lit-html-template-heavy: unsure 🔍 -2% - +2% (-1.54ms - +1.65ms)
    this-change vs tip-of-tree
  • reactive-element-list: unsure 🔍 -1% - +0% (-4.92ms - +3.19ms)
    this-change vs tip-of-tree

update-reflect

  • lit-element-list: 663.86ms - 671.16ms
  • reactive-element-list: unsure 🔍 -0% - +1% (-3.15ms - +5.43ms)
    this-change vs tip-of-tree

Results

lit-element-list

render

VersionAvg timevs
73.01ms - 77.38ms-

update

VersionAvg timevs
678.96ms - 687.01ms-

update-reflect

VersionAvg timevs
663.86ms - 671.16ms-
lit-html-kitchen-sink

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
28.33ms - 30.91ms-unsure 🔍
-5% - +9%
-1.29ms - +2.47ms
unsure 🔍
-2% - +9%
-0.68ms - +2.58ms
tip-of-tree
tip-of-tree
27.67ms - 30.40msunsure 🔍
-8% - +4%
-2.47ms - +1.29ms
-unsure 🔍
-5% - +7%
-1.33ms - +2.05ms
previous-release
previous-release
27.68ms - 29.67msunsure 🔍
-9% - +2%
-2.58ms - +0.68ms
unsure 🔍
-7% - +5%
-2.05ms - +1.33ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
72.17ms - 76.33ms-unsure 🔍
-2% - +6%
-1.78ms - +4.58ms
unsure 🔍
-3% - +5%
-2.26ms - +3.42ms
tip-of-tree
tip-of-tree
70.45ms - 75.25msunsure 🔍
-6% - +2%
-4.58ms - +1.78ms
-unsure 🔍
-5% - +3%
-3.91ms - +2.27ms
previous-release
previous-release
71.73ms - 75.61msunsure 🔍
-5% - +3%
-3.42ms - +2.26ms
unsure 🔍
-3% - +5%
-2.27ms - +3.91ms
-

nop-update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
15.27ms - 16.53ms-unsure 🔍
-10% - +2%
-1.66ms - +0.42ms
unsure 🔍
-4% - +6%
-0.70ms - +0.95ms
tip-of-tree
tip-of-tree
15.69ms - 17.34msunsure 🔍
-3% - +11%
-0.42ms - +1.66ms
-unsure 🔍
-2% - +11%
-0.25ms - +1.73ms
previous-release
previous-release
15.24ms - 16.31msunsure 🔍
-6% - +4%
-0.95ms - +0.70ms
unsure 🔍
-10% - +1%
-1.73ms - +0.25ms
-
lit-html-repeat

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
10.46ms - 11.42ms-unsure 🔍
-4% - +8%
-0.47ms - +0.82ms
unsure 🔍
-4% - +9%
-0.39ms - +0.95ms
tip-of-tree
tip-of-tree
10.33ms - 11.19msunsure 🔍
-7% - +4%
-0.82ms - +0.47ms
-unsure 🔍
-5% - +7%
-0.53ms - +0.73ms
previous-release
previous-release
10.20ms - 11.12msunsure 🔍
-9% - +4%
-0.95ms - +0.39ms
unsure 🔍
-7% - +5%
-0.73ms - +0.53ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
237.86ms - 248.77ms-unsure 🔍
-4% - +3%
-10.27ms - +6.87ms
unsure 🔍
-3% - +3%
-8.45ms - +7.26ms
tip-of-tree
tip-of-tree
238.40ms - 251.62msunsure 🔍
-3% - +4%
-6.87ms - +10.27ms
-unsure 🔍
-3% - +4%
-7.59ms - +9.80ms
previous-release
previous-release
238.26ms - 249.56msunsure 🔍
-3% - +3%
-7.26ms - +8.45ms
unsure 🔍
-4% - +3%
-9.80ms - +7.59ms
-
lit-html-template-heavy

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
51.95ms - 54.27ms-unsure 🔍
-3% - +3%
-1.70ms - +1.43ms
unsure 🔍
-2% - +4%
-0.97ms - +2.20ms
tip-of-tree
tip-of-tree
52.19ms - 54.30msunsure 🔍
-3% - +3%
-1.43ms - +1.70ms
-unsure 🔍
-1% - +4%
-0.76ms - +2.26ms
previous-release
previous-release
51.41ms - 53.57msunsure 🔍
-4% - +2%
-2.20ms - +0.97ms
unsure 🔍
-4% - +1%
-2.26ms - +0.76ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
98.55ms - 100.68ms-unsure 🔍
-2% - +2%
-1.54ms - +1.65ms
unsure 🔍
-1% - +2%
-0.85ms - +2.14ms
tip-of-tree
tip-of-tree
98.37ms - 100.76msunsure 🔍
-2% - +2%
-1.65ms - +1.54ms
-unsure 🔍
-1% - +2%
-1.00ms - +2.18ms
previous-release
previous-release
97.92ms - 100.03msunsure 🔍
-2% - +1%
-2.14ms - +0.85ms
unsure 🔍
-2% - +1%
-2.18ms - +1.00ms
-
reactive-element-list

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
46.86ms - 48.66ms-unsure 🔍
-3% - +2%
-1.54ms - +1.16ms
unsure 🔍
-2% - +3%
-0.95ms - +1.47ms
tip-of-tree
tip-of-tree
46.94ms - 48.95msunsure 🔍
-2% - +3%
-1.16ms - +1.54ms
-unsure 🔍
-2% - +4%
-0.84ms - +1.73ms
previous-release
previous-release
46.70ms - 48.31msunsure 🔍
-3% - +2%
-1.47ms - +0.95ms
unsure 🔍
-4% - +2%
-1.73ms - +0.84ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
681.55ms - 687.57ms-unsure 🔍
-1% - +0%
-4.92ms - +3.19ms
unsure 🔍
-1% - +1%
-3.96ms - +4.12ms
tip-of-tree
tip-of-tree
682.70ms - 688.15msunsure 🔍
-0% - +1%
-3.19ms - +4.92ms
-unsure 🔍
-0% - +1%
-2.88ms - +4.77ms
previous-release
previous-release
681.79ms - 687.17msunsure 🔍
-1% - +1%
-4.12ms - +3.96ms
unsure 🔍
-1% - +0%
-4.77ms - +2.88ms
-

update-reflect

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
689.44ms - 695.34ms-unsure 🔍
-0% - +1%
-3.15ms - +5.43ms
unsure 🔍
-1% - +0%
-4.61ms - +3.26ms
tip-of-tree
tip-of-tree
688.13ms - 694.37msunsure 🔍
-1% - +0%
-5.43ms - +3.15ms
-unsure 🔍
-1% - +0%
-5.88ms - +2.25ms
previous-release
previous-release
690.46ms - 695.67msunsure 🔍
-0% - +1%
-3.26ms - +4.61ms
unsure 🔍
-0% - +1%
-2.25ms - +5.88ms
-

tachometer-reporter-action v2 for Benchmarks

@augustjk
augustjk force-pushed the ssr-react-props branch from 94287f3 to bbeba20 Compare May 9, 2023 20:17

@AndrewJakubowicz AndrewJakubowicz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM from a non domain understanding perspective. I learnt a lot reading through this! An amazingly elegant solution to a thorny issue!

@augustjk
augustjk force-pushed the ssr-react-props branch from bbeba20 to f425ede Compare May 9, 2023 20:36
Comment thread dev-docs/design/ssr-react.md Resolved
Comment thread dev-docs/design/ssr-react.md Resolved
Comment thread dev-docs/design/ssr-react.md Resolved
Comment thread dev-docs/design/ssr-react.md Resolved
Comment thread dev-docs/design/ssr-react.md Resolved
Comment thread dev-docs/design/ssr-react.md Resolved
Comment thread dev-docs/design/ssr-react.md Resolved
Comment thread dev-docs/design/ssr-react.md Resolved
Comment thread dev-docs/design/ssr-react.md Resolved
Comment thread dev-docs/design/ssr-react.md Resolved
Comment thread dev-docs/design/ssr-react.md Resolved

@AndrewJakubowicz AndrewJakubowicz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great! No comments on the code portion, and only minor nits in the docs portion.

Comment thread dev-docs/design/ssr-react.md Resolved
Comment thread dev-docs/design/ssr-react.md Resolved
Comment thread dev-docs/design/ssr-react.md Resolved
Comment thread dev-docs/design/ssr-react.md Resolved
Comment thread packages/labs/react/package.json Resolved
Comment thread packages/labs/ssr-react/README.md Resolved
- Fix wording and typos
@augustjk

Copy link
Copy Markdown
Member Author

@AndrewJakubowicz Thank you for the excellent reviews. Eagle eyes, you have!

@augustjk
augustjk merged commit 7932f7d into main May 16, 2023
@augustjk
augustjk deleted the ssr-react-props branch May 16, 2023 22:59
This was referenced May 24, 2023
@lit-robot lit-robot mentioned this pull request Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[labs/react] Prop/attribute handling for server-rendered wrapped components

2 participants