noDangerouslySetInnerHtmlWithChildren
此内容尚不支持你的语言。
Diagnostic Category: lint/security/noDangerouslySetInnerHtmlWithChildren
Since: v1.0.0
Sources:
- Same as:
react/no-danger-with-children
Report when a DOM element or a component uses both children
and dangerouslySetInnerHTML
prop.
Examples
Section titled ExamplesInvalid
Section titled Invalidcode-block.jsx:4:12 lint/security/noDangerouslySetInnerHtmlWithChildren ━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Avoid passing both children and the dangerouslySetInnerHTML prop.
2 │ return { __html: ‘child’ }
3 │ }
> 4 │ <Component dangerouslySetInnerHTML={createMarkup()}>“child1”</Component>
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5 │
ℹ This is the source of the children prop
2 │ return { __html: ‘child’ }
3 │ }
> 4 │ <Component dangerouslySetInnerHTML={createMarkup()}>“child1”</Component>
│ ^^^^^^^^
5 │
ℹ Setting HTML content will inadvertently override any passed children in React
code-block.jsx:4:12 lint/security/noDangerouslySetInnerHtmlWithChildren ━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Avoid passing both children and the dangerouslySetInnerHTML prop.
2 │ return { __html: ‘child’ }
3 │ }
> 4 │ <Component dangerouslySetInnerHTML={createMarkup()} children=“child1” />
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5 │
ℹ This is the source of the children prop
2 │ return { __html: ‘child’ }
3 │ }
> 4 │ <Component dangerouslySetInnerHTML={createMarkup()} children=“child1” />
│ ^^^^^^^^^^^^^^^^^
5 │
ℹ Setting HTML content will inadvertently override any passed children in React
code-block.js:1:30 lint/security/noDangerouslySetInnerHtmlWithChildren ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Avoid passing both children and the dangerouslySetInnerHTML prop.
> 1 │ React.createElement(‘div’, { dangerouslySetInnerHTML: { __html: ‘HTML’ } }, ‘children’)
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ This is the source of the children prop
> 1 │ React.createElement(‘div’, { dangerouslySetInnerHTML: { __html: ‘HTML’ } }, ‘children’)
│ ^^^^^^^^^^
2 │
ℹ Setting HTML content will inadvertently override any passed children in React