From 479138c264809181842689b300ce30202080307c Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Wed, 23 Jun 2021 16:29:22 +0300 Subject: [PATCH] Chat: Handle "Cannot read property style of null" exception (#1203) --- src/components/left/main/Chat.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/left/main/Chat.tsx b/src/components/left/main/Chat.tsx index 1e8f7b07f..767126b65 100644 --- a/src/components/left/main/Chat.tsx +++ b/src/components/left/main/Chat.tsx @@ -123,12 +123,12 @@ const Chat: FC = ({ // Sets animation excess values when `orderDiff` changes and then resets excess values to animate. useLayoutEffect(() => { - if (animationLevel === 0) { + const element = ref.current; + + if (animationLevel === 0 || !element) { return; } - const element = ref.current!; - // TODO Refactor animation: create `useListAnimation` that owns `orderDiff` and `animationType` if (animationType === ChatAnimationTypes.Opacity) { element.style.opacity = '0';