MCPcopy
hub / github.com/facebook/react / pushLink

Function pushLink

packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js:2850–3024  ·  view source on GitHub ↗
(
  target: Array<Chunk | PrecomputedChunk>,
  props: Object,
  resumableState: ResumableState,
  renderState: RenderState,
  hoistableState: null | HoistableState,
  textEmbedded: boolean,
  formatContext: FormatContext,
)

Source from the content-addressed store, hash-verified

2848}
2849
2850function pushLink(
2851 target: Array<Chunk | PrecomputedChunk>,
2852 props: Object,
2853 resumableState: ResumableState,
2854 renderState: RenderState,
2855 hoistableState: null | HoistableState,
2856 textEmbedded: boolean,
2857 formatContext: FormatContext,
2858): null {
2859 const noscriptTagInScope = formatContext.tagScope & NOSCRIPT_SCOPE;
2860 const isFallback = formatContext.tagScope & FALLBACK_SCOPE;
2861 const rel = props.rel;
2862 const href = props.href;
2863 const precedence = props.precedence;
2864 if (
2865 formatContext.insertionMode === SVG_MODE ||
2866 noscriptTagInScope ||
2867 props.itemProp != null ||
2868 typeof rel !== 'string' ||
2869 typeof href !== 'string' ||
2870 href === ''
2871 ) {
2872 if (__DEV__) {
2873 if (rel === 'stylesheet' && typeof props.precedence === 'string') {
2874 if (typeof href !== 'string' || !href) {
2875 console.error(
2876 'React encountered a `<link rel="stylesheet" .../>` with a `precedence` prop and expected the `href` prop to be a non-empty string but ecountered %s instead. If your intent was to have React hoist and deduplciate this stylesheet using the `precedence` prop ensure there is a non-empty string `href` prop as well, otherwise remove the `precedence` prop.',
2877 getValueDescriptorExpectingObjectForWarning(href),
2878 );
2879 }
2880 }
2881 }
2882 pushLinkImpl(target, props);
2883 return null;
2884 }
2885
2886 if (props.rel === 'stylesheet') {
2887 // This <link> may hoistable as a Stylesheet Resource, otherwise it will emit in place
2888 const key = getResourceKey(href);
2889 if (
2890 typeof precedence !== 'string' ||
2891 props.disabled != null ||
2892 props.onLoad ||
2893 props.onError
2894 ) {
2895 // This stylesheet is either not opted into Resource semantics or has conflicting properties which
2896 // disqualify it for such. We can still create a preload resource to help it load faster on the
2897 // client
2898 if (__DEV__) {
2899 if (typeof precedence === 'string') {
2900 if (props.disabled != null) {
2901 console.error(
2902 'React encountered a `<link rel="stylesheet" .../>` with a `precedence` prop and a `disabled` prop. The presence of the `disabled` prop indicates an intent to manage the stylesheet active state from your from your Component code and React will not hoist or deduplicate this stylesheet. If your intent was to have React hoist and deduplciate this stylesheet using the `precedence` prop remove the `disabled` prop, otherwise remove the `precedence` prop.',
2903 );
2904 } else if (props.onLoad || props.onError) {
2905 const propDescription =
2906 props.onLoad && props.onError
2907 ? '`onLoad` and `onError` props'

Callers 1

pushStartInstanceFunction · 0.85

Calls 12

stringToChunkFunction · 0.90
pushLinkImplFunction · 0.85
escapeTextForBrowserFunction · 0.85
adoptPreloadCredentialsFunction · 0.85
setMethod · 0.80
addMethod · 0.80
getResourceKeyFunction · 0.70
errorMethod · 0.65
getMethod · 0.65
pushMethod · 0.65

Tested by

no test coverage detected