MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / injectInternals

Function injectInternals

code/styling/public/app.js:7126–7162  ·  view source on GitHub ↗
(internals)

Source from the content-addressed store, hash-verified

7124}
7125
7126function injectInternals(internals) {
7127 if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
7128 // No DevTools
7129 return false;
7130 }
7131 var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
7132 if (hook.isDisabled) {
7133 // This isn't a real property on the hook, but it can be set to opt out
7134 // of DevTools integration and associated warnings and logs.
7135 // https://github.com/facebook/react/issues/3877
7136 return true;
7137 }
7138 if (!hook.supportsFiber) {
7139 {
7140 warning(false, 'The installed version of React DevTools is too old and will not work ' + 'with the current version of React. Please update React DevTools. ' + 'https://fb.me/react-devtools');
7141 }
7142 // DevTools exists, even though it doesn't support Fiber.
7143 return true;
7144 }
7145 try {
7146 var rendererID = hook.inject(internals);
7147 // We have successfully injected, so now it is safe to set up hooks.
7148 onCommitFiberRoot = catchErrors(function (root) {
7149 return hook.onCommitFiberRoot(rendererID, root);
7150 });
7151 onCommitFiberUnmount = catchErrors(function (fiber) {
7152 return hook.onCommitFiberUnmount(rendererID, fiber);
7153 });
7154 } catch (err) {
7155 // Catch all errors because it is unsafe to throw during initialization.
7156 {
7157 warning(false, 'React DevTools encountered an error: %s.', err);
7158 }
7159 }
7160 // DevTools exists
7161 return true;
7162}
7163
7164function onCommitRoot(root) {
7165 if (typeof onCommitFiberRoot === 'function') {

Callers 1

ReactFiberReconciler$1Function · 0.70

Calls 2

warningFunction · 0.85
catchErrorsFunction · 0.70

Tested by

no test coverage detected