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

Initial shim of useSyncExternalStore #22211

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

@acdlite
Copy link
Member

@acdlite acdlite commented Aug 30, 2021

This sets up an initial shim implementation of useSyncExternalStore, via the use-sync-external-store package. It's designed to mimic the behavior of the built-in API, but is backwards compatible to any version of React that supports hooks.

I have not yet implemented the built-in API, but once it exists, the use-sync-external-store package will always prefer that one. Library authors can depend on the shim and trust that their users get the correct implementation.

See reactwg/react-18#86 for background on the API.

The tests I've added here are designed to run against both the shim and built-in implementation, using our variant test flag feature. Tests that only apply to concurrent roots will live in a separate suite.

This sets up an initial shim implementation of useSyncExternalStore,
via the use-sync-external-store package. It's designed to mimic the
behavior of the built-in API, but is backwards compatible to any version
of React that supports hooks.

I have not yet implemented the built-in API, but once it exists, the
use-sync-external-store package will always prefer that one. Library
authors can depend on the shim and trust that their users get the
correct implementation.

See reactwg/react-18#86 for background
on the API.

The tests I've added here are designed to run against both the shim and
built-in implementation, using our variant test flag feature. Tests that
only apply to concurrent roots will live in a separate suite.
@acdlite acdlite force-pushed the initial-use-sync-external-store-shim branch 3 times, most recently from a3000c5 to 44b073b Aug 30, 2021
@sizebot
Copy link

@sizebot sizebot commented Aug 30, 2021

Comparing: 46a0f05...44b073b

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 127.60 kB 127.60 kB = 40.73 kB 40.73 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 130.42 kB 130.42 kB = 41.66 kB 41.66 kB
facebook-www/ReactDOM-prod.classic.js = 405.18 kB 405.18 kB = 75.05 kB 75.05 kB
facebook-www/ReactDOM-prod.modern.js = 393.75 kB 393.75 kB = 73.33 kB 73.33 kB
facebook-www/ReactDOMForked-prod.classic.js = 405.18 kB 405.18 kB = 75.05 kB 75.05 kB
oss-experimental/use-sync-external-store/cjs/use-sync-external-store.development.js +2,023.89% 0.49 kB 10.49 kB +1,103.41% 0.32 kB 3.89 kB
oss-stable-semver/use-sync-external-store/cjs/use-sync-external-store.development.js +2,023.89% 0.49 kB 10.49 kB +1,103.41% 0.32 kB 3.89 kB
oss-stable/use-sync-external-store/cjs/use-sync-external-store.development.js +2,023.89% 0.49 kB 10.49 kB +1,103.41% 0.32 kB 3.89 kB
oss-experimental/use-sync-external-store/cjs/use-sync-external-store.production.min.js +247.74% 0.35 kB 1.23 kB +149.06% 0.27 kB 0.66 kB
oss-stable-semver/use-sync-external-store/cjs/use-sync-external-store.production.min.js +247.74% 0.35 kB 1.23 kB +149.06% 0.27 kB 0.66 kB
oss-stable/use-sync-external-store/cjs/use-sync-external-store.production.min.js +247.74% 0.35 kB 1.23 kB +149.06% 0.27 kB 0.66 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/use-sync-external-store/cjs/use-sync-external-store.development.js +2,023.89% 0.49 kB 10.49 kB +1,103.41% 0.32 kB 3.89 kB
oss-stable-semver/use-sync-external-store/cjs/use-sync-external-store.development.js +2,023.89% 0.49 kB 10.49 kB +1,103.41% 0.32 kB 3.89 kB
oss-stable/use-sync-external-store/cjs/use-sync-external-store.development.js +2,023.89% 0.49 kB 10.49 kB +1,103.41% 0.32 kB 3.89 kB
oss-experimental/use-sync-external-store/cjs/use-sync-external-store.production.min.js +247.74% 0.35 kB 1.23 kB +149.06% 0.27 kB 0.66 kB
oss-stable-semver/use-sync-external-store/cjs/use-sync-external-store.production.min.js +247.74% 0.35 kB 1.23 kB +149.06% 0.27 kB 0.66 kB
oss-stable/use-sync-external-store/cjs/use-sync-external-store.production.min.js +247.74% 0.35 kB 1.23 kB +149.06% 0.27 kB 0.66 kB

Generated by 🚫 dangerJS against 44b073b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants