Improve documentation for __html (#6499)

This commit is contained in:
Daniel Lo Nigro
2023-12-19 17:23:51 -08:00
committed by GitHub
parent 303ecae3dd
commit 9ce4afead6

View File

@@ -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}