Moved notice closing to renderer (no leftover nodes)

This commit is contained in:
Ajay Ramachandran
2020-04-14 00:10:20 -04:00
parent 9fafb9cf54
commit 638439a671
5 changed files with 36 additions and 19 deletions

View File

@@ -11,6 +11,8 @@ class SubmissionNotice {
noticeRef: React.MutableRefObject<SubmissionNoticeComponent>;
noticeElement: HTMLDivElement;
constructor(contentContainer: () => any, callback: () => any) {
this.noticeRef = React.createRef();
@@ -34,23 +36,28 @@ class SubmissionNotice {
}
}
let noticeElement = document.createElement("div");
noticeElement.id = "submissionNoticeContainer";
this.noticeElement = document.createElement("div");
this.noticeElement.id = "submissionNoticeContainer";
referenceNode.prepend(noticeElement);
referenceNode.prepend(this.noticeElement);
ReactDOM.render(
<SubmissionNoticeComponent
contentContainer={contentContainer}
callback={callback}
ref={this.noticeRef} />,
noticeElement
ref={this.noticeRef}
closeListener={() => this.close()} />,
this.noticeElement
);
}
update() {
this.noticeRef.current.forceUpdate();
}
close() {
this.noticeElement.remove();
}
}
export default SubmissionNotice;