简中文档

react-no-danger-with-children

NOTE: this rule is included the following rule sets:reactfresh
Enable full set in deno.json:
{
  "lint": {
    "rules": {
      "tags": ["react"] // ...or "fresh"
    }
  }
}
Enable full set using the Deno CLI:
deno lint --rules-tags=react
# or ...
deno lint --rules-tags=fresh
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the include or exclude array in deno.json:
{
  "lint": {
    "rules": {
      "include": ["react-no-danger-with-children"],
      "exclude": ["react-no-danger-with-children"]
    }
  }
}

使用 JSX 子元素与 dangerouslySetInnerHTML 一起是无效的,因为它们将被忽略。

无效:

<div dangerouslySetInnerHTML={{ __html: "<h1>hello</h1>" }}>
  <h1>这将永远不会被渲染</h1>
</div>;

有效:

<div dangerouslySetInnerHTML={{ __html: "<h1>hello</h1>" }} />;

你找到了你需要的东西吗?

编辑此页面
隐私政策