Skip to content

Commit

Permalink
perf: use useMemo
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Jun 25, 2023
1 parent cddcb97 commit 462ea4f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Mentions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import toArray from 'rc-util/lib/Children/toArray';
import useMergedState from 'rc-util/lib/hooks/useMergedState';
import KeyCode from 'rc-util/lib/KeyCode';
import warning from 'rc-util/lib/warning';
import React, { forwardRef, useEffect, useRef, useState } from 'react';
import React, { forwardRef, useEffect, useMemo, useRef, useState } from 'react';
import useEffectState from './hooks/useEffectState';
import KeywordTrigger from './KeywordTrigger';
import MentionsContext from './MentionsContext';
Expand Down Expand Up @@ -113,7 +113,10 @@ const InternalMentions = forwardRef<MentionsRef, MentionsProps>(
...restProps
} = props;

const mergedPrefix = Array.isArray(prefix) ? prefix : [prefix];
const mergedPrefix = useMemo(
() => (Array.isArray(prefix) ? prefix : [prefix]),
[prefix],
);

// =============================== Refs ===============================
const textareaRef = useRef<TextAreaRef>(null);
Expand Down

0 comments on commit 462ea4f

Please sign in to comment.