From 2ec92ac6733e6a4bfebb584f3c68c135b63d1aed Mon Sep 17 00:00:00 2001 From: Gim Date: Fri, 5 Aug 2022 12:15:36 +0800 Subject: [PATCH] fix: side-effect handling --- src/Viewer.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Viewer.tsx b/src/Viewer.tsx index 34a38db16..1ffe7bab1 100644 --- a/src/Viewer.tsx +++ b/src/Viewer.tsx @@ -9,7 +9,8 @@ export default (props: ViewerProps) => { const [ init, setInit ] = React.useState(false); React.useEffect(() => { - document.body.appendChild(defaultContainer.current); + document.body.appendChild(defaultContainer.current); // side-effect needs to be handled. + return ()=>{document.body.removeChild(defaultContainer.current);} // side-effect handling }, []); React.useEffect(() => {