Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix onChange property trigger #153

Merged
merged 2 commits into from
Jun 23, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix trigger of onChange property
  • Loading branch information
niuware committed Jun 23, 2020
commit 2357a776ecda2a1f8c18c33773667770a2ba6e60
6 changes: 3 additions & 3 deletions src/MUIRichTextEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ const MUIRichTextEditor: RefForwardingComponent<TMUIRichTextEditorRef, IMUIRichT
}, [props.value, props.defaultValue])

useEffect(() => {
if (props.onChange) {
props.onChange(editorState)
}
editorStateRef.current = editorState
}, [editorState])

Expand Down Expand Up @@ -483,9 +486,6 @@ const MUIRichTextEditor: RefForwardingComponent<TMUIRichTextEditorRef, IMUIRichT

const handleChange = (state: EditorState) => {
setEditorState(state)
if (props.onChange) {
props.onChange(state)
}
}

const handleBeforeInput = (chars: string): DraftHandleValue => {
Expand Down