Skip to content

Commit 9ce4afe

Browse files
authored
Improve documentation for __html (#6499)
1 parent 303ecae commit 9ce4afe

File tree

1 file changed

+2
-0
lines changed
  • src/content/reference/react-dom/components

1 file changed

+2
-0
lines changed

src/content/reference/react-dom/components/common.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,8 @@ textarea { display: block; margin-top: 5px; margin-bottom: 10px; }
982982
983983
</Sandpack>
984984
985+
The `{__html}` object should be created as close to where the HTML is generated as possible, like the above example does in the `renderMarkdownToHTML` function. This ensures that all raw HTML being used in your code is explicitly marked as such, and that only variables that you expect to contain HTML are passed to `dangerouslySetInnerHTML`. It is not recommended to create the object inline like `<div dangerouslySetInnerHTML={{__html: markup}} />`.
986+
985987
To see why rendering arbitrary HTML is dangerous, replace the code above with this:
986988
987989
```js {1-4,7,8}

0 commit comments

Comments
 (0)