Skip to content

Commit 436a2f2

Browse files
fix: address suggestion with storing root element to class property and use it in reset
1 parent 3236d99 commit 436a2f2

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/components/Toast/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ class ToastCreator {
2626

2727
const el = document.createElement('div');
2828
el.className = 'tyk-toast';
29-
document.body.appendChild(el);
30-
this.root = createRoot(el);
29+
this.el = el;
30+
document.body.appendChild(this.el);
31+
this.root = createRoot(this.el);
3132

3233
this.renderContainer();
3334
}
@@ -118,8 +119,7 @@ class ToastCreator {
118119

119120
if (this.root) {
120121
this.root.unmount();
121-
const el = document.querySelector('.tyk-toast');
122-
if (el) el.remove();
122+
if (this.el) this.el.remove();
123123
}
124124

125125
const newEl = document.createElement('div');

0 commit comments

Comments
 (0)