react icon indicating copy to clipboard operation
react copied to clipboard

Skeleton for store

Open rickhanlonii opened this issue 7 months ago • 2 comments

Note: This doesn't do anything yet. Just sets up some of the skeleton, feature flags, and test files.

Conceptually there's an API to create a store, and then you can read the value with use(store).

For more info on our plans for this API, check out the React Labs post:

Screenshot 2025-05-15 at 12 53 34 PM

rickhanlonii avatar May 15 '25 17:05 rickhanlonii

Comparing: 4448b18760d867f9e009e810571e7a3b8930bb19...4a4147bcbc134da8de81a724bbbf1157ed157ca3

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.js = 6.68 kB 6.68 kB = 1.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 529.74 kB 529.74 kB = 93.49 kB 93.49 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 651.48 kB 651.48 kB = 114.76 kB 114.76 kB
facebook-www/ReactDOM-prod.classic.js +0.03% 675.72 kB 675.91 kB +0.03% 118.85 kB 118.88 kB
facebook-www/ReactDOM-prod.modern.js +0.03% 666.00 kB 666.19 kB +0.03% 117.23 kB 117.27 kB
facebook-www/React-prod.modern.js +2.41% 21.01 kB 21.52 kB +2.01% 5.37 kB 5.47 kB
facebook-www/React-prod.classic.js +2.41% 21.01 kB 21.52 kB +2.03% 5.37 kB 5.47 kB
facebook-www/React-profiling.modern.js +2.36% 21.45 kB 21.95 kB +1.98% 5.45 kB 5.56 kB
facebook-www/React-profiling.classic.js +2.36% 21.45 kB 21.96 kB +1.98% 5.45 kB 5.56 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
facebook-www/React-prod.modern.js +2.41% 21.01 kB 21.52 kB +2.01% 5.37 kB 5.47 kB
facebook-www/React-prod.classic.js +2.41% 21.01 kB 21.52 kB +2.03% 5.37 kB 5.47 kB
facebook-www/React-profiling.modern.js +2.36% 21.45 kB 21.95 kB +1.98% 5.45 kB 5.56 kB
facebook-www/React-profiling.classic.js +2.36% 21.45 kB 21.96 kB +1.98% 5.45 kB 5.56 kB
facebook-www/React-dev.modern.js +0.84% 56.14 kB 56.62 kB +0.80% 12.31 kB 12.40 kB
facebook-www/React-dev.classic.js +0.84% 56.15 kB 56.62 kB +0.80% 12.31 kB 12.41 kB
facebook-react-native/react/cjs/React-prod.js +0.20% 19.09 kB 19.13 kB +0.16% 4.95 kB 4.96 kB

Generated by :no_entry_sign: dangerJS against 4a4147bcbc134da8de81a724bbbf1157ed157ca3

react-sizebot avatar May 15 '25 17:05 react-sizebot

For more info on our plans for this API

Would love support for asyncIterables some day.

nmn avatar May 22 '25 08:05 nmn

Sorry if I'm hijacking this a little, but my question is related and I figured that whoever is invested in this problem space have had some interest in this PR, so I could not think of a better place. I think I see that other devs in the ecosystem are also wondering so I would like to hear what you think about third-party concurrent store experiments like this one: https://github.com/thejustinwalsh/react-concurrent-store

  • Does this solution properly solve the problems in user space, or would the timings in regards to transition lifecycle be off in any way?
  • Is this first class store implementation (this and future PRs) to be used as an alternative to documenting what a store (rtk, react-query, etc) would have to to properly support concurrent features?
  • If the linked lib does not properly solve the issues then is there a proper way for third party libraries solve this themselves today, or do they have to wait for an official implementation?

Thanks // Niklas

nstadigs avatar Sep 15 '25 07:09 nstadigs

There are definitely some edge cases with the userland approach, but I'm optimistic that it will be correct and performant enough to let us try the approach with some real libraries/applications and validate the implications of an API based around reducer plus selectors.

If the general shape of the API proves sufficient for real world uses cases we can explore a built-in API that has similar characteristics but avoids the edge cases which are either incorrect or sub-optimally efficient in userland.

captbaritone avatar Sep 15 '25 09:09 captbaritone