preinit() — react Function Reference
Architecture documentation for the preinit() function in ReactDOMFloat.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 6d07b3fb_e69b_4921_1d4d_786c313f16d3["preinit()"] 3ea12e77_bd9c_ec2a_fb3c_db692f520137["ReactDOMFloat.js"] 6d07b3fb_e69b_4921_1d4d_786c313f16d3 -->|defined in| 3ea12e77_bd9c_ec2a_fb3c_db692f520137 24cdce56_f095_bb7e_3cbd_6bc0a497e302["getValueDescriptorExpectingObjectForWarning()"] 6d07b3fb_e69b_4921_1d4d_786c313f16d3 -->|calls| 24cdce56_f095_bb7e_3cbd_6bc0a497e302 8ae8338e_757b_2763_77d2_0bd8938bd5bd["getValueDescriptorExpectingEnumForWarning()"] 6d07b3fb_e69b_4921_1d4d_786c313f16d3 -->|calls| 8ae8338e_757b_2763_77d2_0bd8938bd5bd style 6d07b3fb_e69b_4921_1d4d_786c313f16d3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-dom/src/shared/ReactDOMFloat.js lines 205–260
export function preinit(href: string, options: PreinitOptions) {
if (__DEV__) {
if (typeof href !== 'string' || !href) {
console.error(
'ReactDOM.preinit(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.',
getValueDescriptorExpectingObjectForWarning(href),
);
} else if (options == null || typeof options !== 'object') {
console.error(
'ReactDOM.preinit(): Expected the `options` argument (second) to be an object with an `as` property describing the type of resource to be preinitialized but encountered %s instead.',
getValueDescriptorExpectingEnumForWarning(options),
);
} else if (options.as !== 'style' && options.as !== 'script') {
console.error(
'ReactDOM.preinit(): Expected the `as` property in the `options` argument (second) to contain a valid value describing the type of resource to be preinitialized but encountered %s instead. Valid values for `as` are "style" and "script".',
getValueDescriptorExpectingEnumForWarning(options.as),
);
}
}
if (typeof href === 'string' && options && typeof options.as === 'string') {
const as = options.as;
const crossOrigin = getCrossOriginStringAs(as, options.crossOrigin);
const integrity =
typeof options.integrity === 'string' ? options.integrity : undefined;
const fetchPriority =
typeof options.fetchPriority === 'string'
? options.fetchPriority
: undefined;
if (as === 'style') {
ReactDOMSharedInternals.d /* ReactDOMCurrentDispatcher */
.S(
/* preinitStyle */
href,
typeof options.precedence === 'string'
? options.precedence
: undefined,
{
crossOrigin,
integrity,
fetchPriority,
},
);
} else if (as === 'script') {
ReactDOMSharedInternals.d /* ReactDOMCurrentDispatcher */
.X(/* preinitScript */ href, {
crossOrigin,
integrity,
fetchPriority,
nonce: typeof options.nonce === 'string' ? options.nonce : undefined,
});
}
}
// We don't error because preinit needs to be resilient to being called in a variety of scopes
// and the runtime may not be capable of responding. The function is optimistic and not critical
// so we favor silent bailout over warning or erroring.
}
Domain
Subdomains
Source
Frequently Asked Questions
What does preinit() do?
preinit() is a function in the react codebase, defined in packages/react-dom/src/shared/ReactDOMFloat.js.
Where is preinit() defined?
preinit() is defined in packages/react-dom/src/shared/ReactDOMFloat.js at line 205.
What does preinit() call?
preinit() calls 2 function(s): getValueDescriptorExpectingEnumForWarning, getValueDescriptorExpectingObjectForWarning.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free