Update Flight fixture to use use() instead of Promise as a child (#26715)
The Promise as a child case seems buggy. It ends up throwing the Promise as fatal when used in Sync rendering.
Sebastian Markbåge committed
Apr 24, 2023 at 14:00 UTC
9c58a0b6475509f9124da578207aa0d3b7364035
1 file changed
+6
-5
fixtures/flight/src/index.js
+6
-5
@@ -1,5 +1,5 @@
1
import * as React from 'react';
2
-import {Suspense} from 'react';
2
+import {use, Suspense} from 'react';
3
import ReactDOM from 'react-dom/client';
4
import {createFromFetch, encodeReply} from 'react-server-dom-webpack/client';
5
@@ -27,7 +27,8 @@ let data = createFromFetch(
27
}
28
);
29
30
-// TODO: This transition shouldn't really be necessary but it is for now.
31
-React.startTransition(() => {
32
- ReactDOM.hydrateRoot(document, data);
33
-});
30
+function Shell({data}) {
31
+ return use(data);
32
+}
33
+
34
+ReactDOM.hydrateRoot(document, <Shell data={data} />);