Skip to content

Commit

Permalink
Move useMemo out of an if
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Eklund committed Jul 16, 2022
1 parent bc231a6 commit 3318a2c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/HighlightWithinTextarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ const HighlightWithinTextarea = React.forwardRef<Editor, HWTAProps>(

const contentState = editorState.getCurrentContent();
let decorator;
if (highlight) {
decorator = useMemo(
() => createDecorator(contentState, highlight as Highlight, value),
[contentState, highlight, value]
);
}
decorator = useMemo(
() =>
highlight &&
createDecorator(contentState, highlight as Highlight, value),
[contentState, highlight, value]
);

editorState = EditorState.set(editorState, {
decorator: decorator,
Expand Down Expand Up @@ -149,7 +149,7 @@ const HighlightWithinTextarea = React.forwardRef<Editor, HWTAProps>(
delete newProps.selection;
delete newProps.placeholder;
delete newProps.onChange;
delete (newProps as {value?: string}).value;
delete (newProps as { value?: string }).value;

return (
<Editor
Expand Down

0 comments on commit 3318a2c

Please sign in to comment.