Home / Function/ validateLinkPropsForStyleResource() — react Function Reference

validateLinkPropsForStyleResource() — react Function Reference

Architecture documentation for the validateLinkPropsForStyleResource() function in ReactDOMResourceValidation.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  e3a1502a_82c2_a7bb_97cf_388efa2f3ef1["validateLinkPropsForStyleResource()"]
  ec6879c0_0ed5_4845_5e7d_01fe831eda53["ReactDOMResourceValidation.js"]
  e3a1502a_82c2_a7bb_97cf_388efa2f3ef1 -->|defined in| ec6879c0_0ed5_4845_5e7d_01fe831eda53
  97ef147a_20c5_db7b_67d2_eafb9a74dd31["propNamesListJoin()"]
  e3a1502a_82c2_a7bb_97cf_388efa2f3ef1 -->|calls| 97ef147a_20c5_db7b_67d2_eafb9a74dd31
  style e3a1502a_82c2_a7bb_97cf_388efa2f3ef1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-dom-bindings/src/shared/ReactDOMResourceValidation.js lines 10–41

export function validateLinkPropsForStyleResource(props: any): boolean {
  if (__DEV__) {
    // This should only be called when we know we are opting into Resource semantics (i.e. precedence is not null)
    const {href, onLoad, onError, disabled} = props;
    const includedProps = [];
    if (onLoad) includedProps.push('`onLoad`');
    if (onError) includedProps.push('`onError`');
    if (disabled != null) includedProps.push('`disabled`');

    let includedPropsPhrase = propNamesListJoin(includedProps, 'and');
    includedPropsPhrase += includedProps.length === 1 ? ' prop' : ' props';
    const withArticlePhrase =
      includedProps.length === 1
        ? 'an ' + includedPropsPhrase
        : 'the ' + includedPropsPhrase;

    if (includedProps.length) {
      console.error(
        'React encountered a <link rel="stylesheet" href="%s" ... /> with a `precedence` prop that' +
          ' also included %s. The presence of loading and error handlers indicates an intent to manage' +
          ' the stylesheet loading 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 %s, otherwise remove the `precedence` prop.',
        href,
        withArticlePhrase,
        includedPropsPhrase,
      );
      return true;
    }
  }
  return false;
}

Domain

Subdomains

Frequently Asked Questions

What does validateLinkPropsForStyleResource() do?
validateLinkPropsForStyleResource() is a function in the react codebase, defined in packages/react-dom-bindings/src/shared/ReactDOMResourceValidation.js.
Where is validateLinkPropsForStyleResource() defined?
validateLinkPropsForStyleResource() is defined in packages/react-dom-bindings/src/shared/ReactDOMResourceValidation.js at line 10.
What does validateLinkPropsForStyleResource() call?
validateLinkPropsForStyleResource() calls 1 function(s): propNamesListJoin.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free