From 9ce4afead624114d5f831c70ea31c14feb5965ce Mon Sep 17 00:00:00 2001 From: Daniel Lo Nigro Date: Tue, 19 Dec 2023 17:23:51 -0800 Subject: [PATCH] Improve documentation for __html (#6499) --- src/content/reference/react-dom/components/common.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/content/reference/react-dom/components/common.md b/src/content/reference/react-dom/components/common.md index 11719112e..610742735 100644 --- a/src/content/reference/react-dom/components/common.md +++ b/src/content/reference/react-dom/components/common.md @@ -982,6 +982,8 @@ textarea { display: block; margin-top: 5px; margin-bottom: 10px; } +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 `
`. + To see why rendering arbitrary HTML is dangerous, replace the code above with this: ```js {1-4,7,8}