Skip to content

Commit

Permalink
fix(code-editor): forward ref to textarea
Browse files Browse the repository at this point in the history
  • Loading branch information
billiegoose committed Nov 28, 2018
1 parent b3d9c9b commit ae36406
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/CodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ export const supportedLanguages = {
...optionalSupport,
};

const CodeEditorView = (props: ICodeEditorProps & { className: string }) => {
const CodeEditorView = React.forwardRef((props: ICodeEditorProps & { className: string }, ref: any) => {
const { className, language, onChange = noop, value } = props;

const highlightCodeCallback = useCallback(() => highlightCode(value, language), [value, language]);

return (
<div className={className}>
<Editor value={value} onValueChange={onChange} highlight={highlightCodeCallback} padding={10} />
<Editor ref={ref} value={value} onValueChange={onChange} highlight={highlightCodeCallback} padding={10} />
</div>
);
};
});

// @ts-ignore
export const CodeEditor = styled<ICodeEditorProps>(CodeEditorView as any)`
Expand Down

0 comments on commit ae36406

Please sign in to comment.