Skip to content

Commit

Permalink
Fix error when navigating away of threads view (mattermost#29543)
Browse files Browse the repository at this point in the history
Co-authored-by: Mattermost Build <[email protected]>
  • Loading branch information
larkox and mattermost-build authored Jan 21, 2025
1 parent c3fc894 commit 03b678e
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
import type {Instance} from '@popperjs/core';
import debounce from 'lodash/debounce';
import type React from 'react';
import {useCallback, useEffect, useLayoutEffect, useState} from 'react';
import {useEffect, useLayoutEffect, useMemo, useState} from 'react';

import type {MarkdownMode} from 'utils/markdown/apply_markdown';

type WideMode = 'wide' | 'normal' | 'narrow' | 'min';

const useResponsiveFormattingBar = (ref: React.RefObject<HTMLDivElement>): WideMode => {
const [wideMode, setWideMode] = useState<WideMode>('wide');
const handleResize = useCallback(debounce(() => {
if (ref.current?.clientWidth === undefined) {
const handleResize = useMemo(() => debounce(() => {
if (ref.current?.clientWidth == null) {
return;
}
if (ref.current.clientWidth > 640) {
Expand All @@ -29,7 +29,7 @@ const useResponsiveFormattingBar = (ref: React.RefObject<HTMLDivElement>): WideM
if (ref.current.clientWidth < 310) {
setWideMode('min');
}
}, 10), []);
}, 10), [ref]);

useLayoutEffect(() => {
if (!ref.current) {
Expand Down

0 comments on commit 03b678e

Please sign in to comment.