Skip to content

Commit e2fb2fc

Browse files
Only run replaceChildren with htmlContainer change (#2356)
* Only run replaceChildren with htmlContainer change * Create weak-hotels-shout.md Co-authored-by: Cole Bemis <[email protected]>
1 parent 61a93e2 commit e2fb2fc

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.changeset/weak-hotels-shout.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/react": patch
3+
---
4+
5+
MarkdownViewer bug fix: Only run `replaceChildren` when `htmlContainer` changes

src/drafts/MarkdownViewer/MarkdownViewer.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ const MarkdownViewer = ({
107107
// If we were to inject the `...htmlContainer.children` instead of the container element itself,
108108
// those children elements would be moved from the `htmlContainer` to the `outputContainer`. Then if
109109
// other effects use `htmlContainer.querySelectorAll`, they wouldn't find any elements to affect
110-
useEffect(() => outputContainerRef.current?.replaceChildren(htmlContainer))
110+
useEffect(() => outputContainerRef.current?.replaceChildren(htmlContainer), [htmlContainer])
111111

112112
return loading ? (
113113
<Box sx={{display: 'flex', justifyContent: 'space-around', p: 2}}>

0 commit comments

Comments
 (0)