Skip to content

Don't inject timeline hooks unless React supports profiling #23151

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions packages/react-reconciler/src/ReactFiberDevToolsHook.new.js
Original file line number Diff line number Diff line change
@@ -74,11 +74,19 @@ export function injectInternals(internals: Object): boolean {
return true;
}
try {
rendererID = hook.inject({
...internals,
getLaneLabelMap,
injectProfilingHooks,
});
if (enableSchedulingProfiler) {
// Conditionally inject these hooks only if Timeline profiler is supported by this build.
// This gives DevTools a way to feature detect that isn't tied to version number
// (since profiling and timeline are controlled by different feature flags).
internals = {
...internals,
getLaneLabelMap,
injectProfilingHooks,
};
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getLaneLabelMap and injectProfilingHooks are already optional parameters (not injected by earlier versions of react) so it's safe to conditionally include them.


rendererID = hook.inject(internals);

// We have successfully injected, so now it is safe to set up hooks.
injectedHook = hook;
} catch (err) {
18 changes: 13 additions & 5 deletions packages/react-reconciler/src/ReactFiberDevToolsHook.old.js
Original file line number Diff line number Diff line change
@@ -74,11 +74,19 @@ export function injectInternals(internals: Object): boolean {
return true;
}
try {
rendererID = hook.inject({
...internals,
getLaneLabelMap,
injectProfilingHooks,
});
if (enableSchedulingProfiler) {
// Conditionally inject these hooks only if Timeline profiler is supported by this build.
// This gives DevTools a way to feature detect that isn't tied to version number
// (since profiling and timeline are controlled by different feature flags).
internals = {
...internals,
getLaneLabelMap,
injectProfilingHooks,
};
}

rendererID = hook.inject(internals);

// We have successfully injected, so now it is safe to set up hooks.
injectedHook = hook;
} catch (err) {