From 68f8d2e0a72be64a128588effe3a8af89aa4a7b3 Mon Sep 17 00:00:00 2001 From: Roy Sutton Date: Tue, 16 Jun 2020 12:46:20 -0400 Subject: [PATCH] PLAT-110785: Fix useFloatingLayer to defer update until mounted (#2792) Enact-DCO-1.0-Signed-off-by: Roy Sutton roy.sutton@lge.com Reviewed-By: Jeremy Thomas (jeremy.thomas@lge.com) Integrated-By: Ryan Duffy (ryan.duffy@lge.com) --- packages/ui/FloatingLayer/useFloatingLayer.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/ui/FloatingLayer/useFloatingLayer.js b/packages/ui/FloatingLayer/useFloatingLayer.js index 39d88e51a6..b67337e858 100644 --- a/packages/ui/FloatingLayer/useFloatingLayer.js +++ b/packages/ui/FloatingLayer/useFloatingLayer.js @@ -11,9 +11,12 @@ function useFloatingLayer () { }, [setId]); const registerFloatingLayer = React.useContext(FloatingLayerContext); - if (registerFloatingLayer) { - registerFloatingLayer(handler); - } + + React.useEffect(() => { + if (registerFloatingLayer) { + registerFloatingLayer(handler); + } + }, [handler, registerFloatingLayer]); return {floatingLayerId}; }