Skip to content

Instantly share code, notes, and snippets.

@gustav1105
Created February 16, 2020 10:31
Show Gist options
  • Save gustav1105/32559882f835416a4c7b510789945f07 to your computer and use it in GitHub Desktop.
Save gustav1105/32559882f835416a4c7b510789945f07 to your computer and use it in GitHub Desktop.
editor-state-and-focus-functions
const editor = React.useRef<Editor>(null);
const [editorState, setEditorState] = React.useState<EditorState>(
EditorState.createEmpty(
new CompositeDecorator([
{
strategy: linkStrategy,
component: DecoratedLink
}
])
)
);
const focusEditor = React.useCallback(() => {
if (editor.current) {
editor.current.focus();
}
}, [editor]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment