Chat: Handle "Cannot read property style of null" exception (#1203)

This commit is contained in:
Alexander Zinchuk 2021-06-23 16:29:22 +03:00
parent 65f583a8ec
commit 479138c264

View File

@ -123,12 +123,12 @@ const Chat: FC<OwnProps & StateProps & DispatchProps> = ({
// 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';