Created
February 6, 2019 18:58
-
-
Save schabluk/47ffecd16ec7411fa2d764ddd9228677 to your computer and use it in GitHub Desktop.
useRef on HTML element with TypeScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function DraftEditor({ metaData, readOnly = false, decorators = [] }: IDraftEditor) { | |
const editorRef = useRef<HTMLDivElement>(null) | |
const handleFocusClick = () => { | |
const { current: editor } = editorRef | |
if (editor) { editor.focus() } | |
} | |
return ( | |
<div ref={editorRef} onClick={handleFocusClick} /> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment