dillon1000/react
Commit
Browse files [Flight] Add Support for Map and Set (#26933)
We already support these in the sense that they're Iterable so they just get serialized as arrays. However, these are part of the Structured Clone algorithm [and should be supported](https://github.com/facebook/react/issues/25687). The encoding is simply the same form as the Iterable, which is conveniently the same as the constructor argument. The difference is that now there's a separate reference to it. It's a bit awkward because for multiple reference to the same value, it'd be a new Map/Set instance for each reference. So to encode sharing, it needs one level of indirection with its own ID. That's not really a big deal for other types since they're inline anyway - but since this needs to be outlined it creates possibly two ids where there only needs to be one or zero. One variant would be to encode this in the row type. Another variant would be something like what we do for React Elements where they're arrays but tagged with a symbol. For simplicity I stick with the simple outlining for now.
Changed paths6 files
First-parent comparisonpackages/react-client/src/ReactFlightClient.js ModifiedM packages/react-client/src/ReactFlightReplyClient.js ModifiedM packages/react-client/src/__tests__/ReactFlight-test.js ModifiedM packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMReply-test.js ModifiedM packages/react-server/src/ReactFlightReplyServer.js ModifiedM packages/react-server/src/ReactFlightServer.js ModifiedPatch
Files changed
Rendering syntax-highlighted changes…