( target: Array<Chunk | PrecomputedChunk>, props: Object, renderState: RenderState, formatContext: FormatContext, )
| 3527 | } |
| 3528 | |
| 3529 | function pushTitle( |
| 3530 | target: Array<Chunk | PrecomputedChunk>, |
| 3531 | props: Object, |
| 3532 | renderState: RenderState, |
| 3533 | formatContext: FormatContext, |
| 3534 | ): ReactNodeList { |
| 3535 | const noscriptTagInScope = formatContext.tagScope & NOSCRIPT_SCOPE; |
| 3536 | const isFallback = formatContext.tagScope & FALLBACK_SCOPE; |
| 3537 | if (__DEV__) { |
| 3538 | if (hasOwnProperty.call(props, 'children')) { |
| 3539 | const children = props.children; |
| 3540 | |
| 3541 | const child = Array.isArray(children) |
| 3542 | ? children.length < 2 |
| 3543 | ? children[0] |
| 3544 | : null |
| 3545 | : children; |
| 3546 | |
| 3547 | if (Array.isArray(children) && children.length > 1) { |
| 3548 | console.error( |
| 3549 | 'React expects the `children` prop of <title> tags to be a string, number, bigint, or object with a novel `toString` method but found an Array with length %s instead.' + |
| 3550 | ' Browsers treat all child Nodes of <title> tags as Text content and React expects to be able to convert `children` of <title> tags to a single string value' + |
| 3551 | ' which is why Arrays of length greater than 1 are not supported. When using JSX it can be common to combine text nodes and value nodes.' + |
| 3552 | ' For example: <title>hello {nameOfUser}</title>. While not immediately apparent, `children` in this case is an Array with length 2. If your `children` prop' + |
| 3553 | ' is using this form try rewriting it using a template string: <title>{`hello ${nameOfUser}`}</title>.', |
| 3554 | children.length, |
| 3555 | ); |
| 3556 | } else if (typeof child === 'function' || typeof child === 'symbol') { |
| 3557 | const childType = |
| 3558 | typeof child === 'function' ? 'a Function' : 'a Sybmol'; |
| 3559 | console.error( |
| 3560 | 'React expect children of <title> tags to be a string, number, bigint, or object with a novel `toString` method but found %s instead.' + |
| 3561 | ' Browsers treat all child Nodes of <title> tags as Text content and React expects to be able to convert children of <title>' + |
| 3562 | ' tags to a single string value.', |
| 3563 | childType, |
| 3564 | ); |
| 3565 | } else if (child && child.toString === {}.toString) { |
| 3566 | if (child.$$typeof != null) { |
| 3567 | console.error( |
| 3568 | 'React expects the `children` prop of <title> tags to be a string, number, bigint, or object with a novel `toString` method but found an object that appears to be' + |
| 3569 | ' a React element which never implements a suitable `toString` method. Browsers treat all child Nodes of <title> tags as Text content and React expects to' + |
| 3570 | ' be able to convert children of <title> tags to a single string value which is why rendering React elements is not supported. If the `children` of <title> is' + |
| 3571 | ' a React Component try moving the <title> tag into that component. If the `children` of <title> is some HTML markup change it to be Text only to be valid HTML.', |
| 3572 | ); |
| 3573 | } else { |
| 3574 | console.error( |
| 3575 | 'React expects the `children` prop of <title> tags to be a string, number, bigint, or object with a novel `toString` method but found an object that does not implement' + |
| 3576 | ' a suitable `toString` method. Browsers treat all child Nodes of <title> tags as Text content and React expects to be able to convert children of <title> tags' + |
| 3577 | ' to a single string value. Using the default `toString` method available on every object is almost certainly an error. Consider whether the `children` of this <title>' + |
| 3578 | ' is an object in error and change it to a string or number value if so. Otherwise implement a `toString` method that React can use to produce a valid <title>.', |
| 3579 | ); |
| 3580 | } |
| 3581 | } |
| 3582 | } |
| 3583 | } |
| 3584 | |
| 3585 | if ( |
| 3586 | formatContext.insertionMode !== SVG_MODE && |
no test coverage detected