CompositionInput: Fix high CPU usage
This commit is contained in:
parent
a1270867ff
commit
17f212ffcf
3 changed files with 26 additions and 16 deletions
|
@ -27,7 +27,7 @@ import {
|
|||
search,
|
||||
} from './emoji/lib';
|
||||
import { LocalizerType } from '../types/Util';
|
||||
import { mergeRefs } from './_util';
|
||||
import { createRefMerger } from './_util';
|
||||
|
||||
const MAX_LENGTH = 64 * 1024;
|
||||
const colonsRegex = /(?:^|\s):[a-z0-9-_+]+:?/gi;
|
||||
|
@ -237,6 +237,7 @@ export const CompositionInput = ({
|
|||
const focusRef = React.useRef(false);
|
||||
const editorStateRef = React.useRef<EditorState>(editorRenderState);
|
||||
const rootElRef = React.useRef<HTMLDivElement>();
|
||||
const rootElRefMerger = React.useMemo(createRefMerger, []);
|
||||
|
||||
// This function sets editorState and also keeps a reference to the newly set
|
||||
// state so we can reference the state in effects and callbacks without
|
||||
|
@ -757,7 +758,7 @@ export const CompositionInput = ({
|
|||
{({ measureRef }) => (
|
||||
<div
|
||||
className="module-composition-input__input"
|
||||
ref={mergeRefs(popperRef, measureRef, rootElRef)}
|
||||
ref={rootElRefMerger(popperRef, measureRef, rootElRef)}
|
||||
>
|
||||
<div
|
||||
className={classNames(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue