Skip to content

Commit 7d8706b

Browse files
committed
fix: repeat rendering (#3)
1 parent 617330d commit 7d8706b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/content-script/index.jsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import './styles.scss'
2+
import { unmountComponentAtNode } from 'react-dom'
23
import { render } from 'preact'
34
import DecisionCard from '../components/DecisionCard'
45
import { config as siteConfig } from './site-adapters'
@@ -27,13 +28,19 @@ async function mountComponent(siteConfig, userConfig) {
2728
)
2829
return
2930

30-
document.querySelectorAll('.chat-gpt-container').forEach((e) => e.remove())
31+
document.querySelectorAll('.chat-gpt-container').forEach((e) => {
32+
unmountComponentAtNode(e)
33+
e.remove()
34+
})
3135

3236
let question
3337
if (userConfig.inputQuery) question = await getInput([userConfig.inputQuery])
3438
if (!question && siteConfig) question = await getInput(siteConfig.inputQuery)
3539

36-
document.querySelectorAll('.chat-gpt-container').forEach((e) => e.remove())
40+
document.querySelectorAll('.chat-gpt-container').forEach((e) => {
41+
unmountComponentAtNode(e)
42+
e.remove()
43+
})
3744
const container = document.createElement('div')
3845
container.className = 'chat-gpt-container'
3946
render(

0 commit comments

Comments
 (0)