From 1a007754b37b1ae13c5b5986b8551a35cf5ef851 Mon Sep 17 00:00:00 2001 From: kamre Date: Mon, 6 Sep 2021 19:17:10 +0700 Subject: [PATCH] Switch from `useEffect` to `useLayoutEffect` in the `RootPortal` component. (#1120) Co-authored-by: Harshil Sharma --- webapp/src/components/rootPortal.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/src/components/rootPortal.tsx b/webapp/src/components/rootPortal.tsx index 88ac00aa4..5e17db6f5 100644 --- a/webapp/src/components/rootPortal.tsx +++ b/webapp/src/components/rootPortal.tsx @@ -1,7 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import React, {useState, useEffect} from 'react' +import React, {useState, useLayoutEffect} from 'react' import ReactDOM from 'react-dom' type Props = { @@ -12,7 +12,7 @@ const RootPortal = React.memo((props: Props): JSX.Element => { const [el] = useState(document.createElement('div')) const rootPortal = document.getElementById('focalboard-root-portal') - useEffect(() => { + useLayoutEffect(() => { if (rootPortal) { rootPortal.appendChild(el) }