dillon1000/react

Commit

[Flight] Add getCacheForType() to the dispatcher (#20315)

* Remove react/unstable_cache

We're probably going to make it available via the dispatcher. Let's remove this for now.

* Add readContext() to the dispatcher

On the server, it will be per-request.

On the client, there will be some way to shadow it.

For now, I provide it on the server, and throw on the client.

* Use readContext() from react-fetch

This makes it work on the server (but not on the client until we implement it there.)

Updated the test to use Server Components. Now it passes.

* Fixture: Add fetch from a Server Component

* readCache -> getCacheForType<T>

* Add React.unstable_getCacheForType

* Add a feature flag

* Fix Flow

* Add react-suspense-test-utils and port tests

* Remove extra Map lookup

* Unroll async/await because build system

* Add some error coverage and retry

* Add unstable_getCacheForType to Flight entry
Browse files
Changed paths37 files
First-parent comparison
M fixtures/flight/server/cli.server.js ModifiedM fixtures/flight/src/App.server.js ModifiedM packages/react-debug-tools/src/ReactDebugHooks.js ModifiedM packages/react-dom/src/server/ReactPartialRendererHooks.js ModifiedM packages/react-fetch/src/ReactFetchBrowser.js ModifiedM packages/react-fetch/src/ReactFetchNode.js ModifiedM packages/react-fetch/src/__tests__/ReactFetchNode-test.js ModifiedM packages/react-reconciler/src/ReactFiberHooks.new.js ModifiedM packages/react-reconciler/src/ReactFiberHooks.old.js ModifiedM packages/react-reconciler/src/ReactInternalTypes.js ModifiedM packages/react-server/src/ReactFlightServer.js ModifiedA packages/react-suspense-test-utils/README.md AddedR packages/react/unstable-cache.js →packages/react-suspense-test-utils/index.js RenamedA packages/react-suspense-test-utils/npm/index.js AddedA packages/react-suspense-test-utils/package.json AddedA packages/react-suspense-test-utils/src/ReactSuspenseTestUtils.js AddedM packages/react/index.classic.fb.js ModifiedM packages/react/index.experimental.js ModifiedM packages/react/index.js ModifiedM packages/react/index.modern.fb.js ModifiedM packages/react/package.json ModifiedM packages/react/src/React.js ModifiedM packages/react/src/ReactHooks.js ModifiedD packages/react/src/__tests__/ReactCache-test.js DeletedD packages/react/src/cache/ReactCache.js DeletedM packages/react/unstable-index.server.experimental.js ModifiedM packages/shared/ReactFeatureFlags.js ModifiedM packages/shared/forks/ReactFeatureFlags.native-fb.js ModifiedM packages/shared/forks/ReactFeatureFlags.native-oss.js ModifiedM packages/shared/forks/ReactFeatureFlags.test-renderer.js ModifiedM packages/shared/forks/ReactFeatureFlags.test-renderer.native.js ModifiedM packages/shared/forks/ReactFeatureFlags.test-renderer.www.js ModifiedM packages/shared/forks/ReactFeatureFlags.testing.js ModifiedM packages/shared/forks/ReactFeatureFlags.testing.www.js ModifiedM packages/shared/forks/ReactFeatureFlags.www.js ModifiedM scripts/error-codes/codes.json ModifiedM scripts/rollup/bundles.js Modified
Patch

Files changed

Rendering syntax-highlighted changes…