mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-23 20:23:08 +00:00
Improve documentation for __html (#6499)
This commit is contained in:
@@ -982,6 +982,8 @@ textarea { display: block; margin-top: 5px; margin-bottom: 10px; }
|
||||
|
||||
</Sandpack>
|
||||
|
||||
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}} />`.
|
||||
|
||||
To see why rendering arbitrary HTML is dangerous, replace the code above with this:
|
||||
|
||||
```js {1-4,7,8}
|
||||
|
||||
Reference in New Issue
Block a user