Skip to content

Commit

Permalink
Add Profiler mode to fixtures even if React DevTools is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Dec 20, 2024
1 parent 518d06d commit d4e49b6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
24 changes: 15 additions & 9 deletions fixtures/flight/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import {use, Suspense, useState, startTransition} from 'react';
import {use, Suspense, useState, startTransition, Profiler} from 'react';
import ReactDOM from 'react-dom/client';
import {createFromFetch, encodeReply} from 'react-server-dom-webpack/client';

Expand Down Expand Up @@ -54,14 +54,20 @@ async function hydrateApp() {
}
);

ReactDOM.hydrateRoot(document, <Shell data={root} />, {
// TODO: This part doesn't actually work because the server only returns
// form state during the request that submitted the form. Which means it
// the state needs to be transported as part of the HTML stream. We intend
// to add a feature to Fizz for this, but for now it's up to the
// metaframework to implement correctly.
formState: formState,
});
ReactDOM.hydrateRoot(
document,
<Profiler>
<Shell data={root} />
</Profiler>,
{
// TODO: This part doesn't actually work because the server only returns
// form state during the request that submitted the form. Which means it
// the state needs to be transported as part of the HTML stream. We intend
// to add a feature to Fizz for this, but for now it's up to the
// metaframework to implement correctly.
formState: formState,
}
);
}

// Remove this line to simulate MPA behavior
Expand Down
8 changes: 7 additions & 1 deletion fixtures/ssr/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import React from 'react';
import {Profiler} from 'react';
import {hydrateRoot} from 'react-dom/client';

import App from './components/App';

hydrateRoot(document, <App assets={window.assetManifest} />);
hydrateRoot(
document,
<Profiler>
<App assets={window.assetManifest} />
</Profiler>
);

0 comments on commit d4e49b6

Please sign in to comment.