Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
docs: in react hooks example, limit createEmpty calls (#2432)
Browse files Browse the repository at this point in the history
Summary:
In the React hooks example, `EditorState.createEmpty` will be called each time the component is rendered. By wrapping it in a function, it will only be called once per instance of the MyEditor component.
Pull Request resolved: #2432

Reviewed By: claudiopro

Differential Revision: D21652207

Pulled By: mrkev

fbshipit-source-id: 0c24a4e84718227b4e89d1c810b2558ffd51384d
  • Loading branch information
benatkin authored and facebook-github-bot committed May 20, 2020
1 parent e5e293f commit 05e838e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ import 'draft-js/dist/Draft.css';

function MyEditor() {
const [editorState, setEditorState] = React.useState(
EditorState.createEmpty(),
() => EditorState.createEmpty(),
);

return <Editor editorState={editorState} onChange={setEditorState} />;
Expand Down

0 comments on commit 05e838e

Please sign in to comment.