Fix error when navigating away of threads view (#29543)
Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c3fc894111
Коммит
03b678e860
@@ -4,7 +4,7 @@
|
|||||||
import type {Instance} from '@popperjs/core';
|
import type {Instance} from '@popperjs/core';
|
||||||
import debounce from 'lodash/debounce';
|
import debounce from 'lodash/debounce';
|
||||||
import type React from 'react';
|
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';
|
import type {MarkdownMode} from 'utils/markdown/apply_markdown';
|
||||||
|
|
||||||
@@ -12,8 +12,8 @@ type WideMode = 'wide' | 'normal' | 'narrow' | 'min';
|
|||||||
|
|
||||||
const useResponsiveFormattingBar = (ref: React.RefObject<HTMLDivElement>): WideMode => {
|
const useResponsiveFormattingBar = (ref: React.RefObject<HTMLDivElement>): WideMode => {
|
||||||
const [wideMode, setWideMode] = useState<WideMode>('wide');
|
const [wideMode, setWideMode] = useState<WideMode>('wide');
|
||||||
const handleResize = useCallback(debounce(() => {
|
const handleResize = useMemo(() => debounce(() => {
|
||||||
if (ref.current?.clientWidth === undefined) {
|
if (ref.current?.clientWidth == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ref.current.clientWidth > 640) {
|
if (ref.current.clientWidth > 640) {
|
||||||
@@ -29,7 +29,7 @@ const useResponsiveFormattingBar = (ref: React.RefObject<HTMLDivElement>): WideM
|
|||||||
if (ref.current.clientWidth < 310) {
|
if (ref.current.clientWidth < 310) {
|
||||||
setWideMode('min');
|
setWideMode('min');
|
||||||
}
|
}
|
||||||
}, 10), []);
|
}, 10), [ref]);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (!ref.current) {
|
if (!ref.current) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user