dillon1000/react

Commit

Change .model getter to .readRoot method (#18382)

Originally the idea was to hide all suspending behind getters or proxies.
However, this has some issues with perf on hot code like React elements.

It also makes it too easy to accidentally access it the first time in an
effect or callback where things aren't allowed to suspend. Making it
an explicit method call avoids this issue.

All other suspending has moved to explicit lazy blocks (and soon elements).
The only thing remaining is the root. We could require the root to be an
element or block but that creates an unfortunate indirection unnecessarily.

Instead, I expose a readRoot method on the response. Typically we try to
avoid virtual dispatch but in this case, it's meant that you build
abstractions on top of a Flight response so passing it a round is useful.
Browse files
Changed paths12 files
First-parent comparison
M fixtures/flight-browser/index.html ModifiedM fixtures/flight/src/App.js ModifiedM fixtures/flight/src/index.js ModifiedM packages/react-client/src/ReactFlightClient.js ModifiedM packages/react-client/src/ReactFlightClientStream.js ModifiedM packages/react-client/src/__tests__/ReactFlight-test.js ModifiedM packages/react-flight-dom-relay/src/ReactFlightDOMRelayClient.js ModifiedM packages/react-flight-dom-relay/src/__tests__/ReactFlightDOMRelay-test.internal.js ModifiedM packages/react-flight-dom-webpack/src/ReactFlightDOMClient.js ModifiedM packages/react-flight-dom-webpack/src/__tests__/ReactFlightDOM-test.js ModifiedM packages/react-flight-dom-webpack/src/__tests__/ReactFlightDOMBrowser-test.js ModifiedM packages/react-noop-renderer/src/ReactNoopFlightClient.js Modified
Patch

Files changed

Rendering syntax-highlighted changes…