()
| 3 | import { useRef } from 'react'; |
| 4 | |
| 5 | export function Component() { |
| 6 | let $edit = useRef<ReactCodeMirrorRef | null>(null); |
| 7 | function refCallack(editor: ReactCodeMirrorRef) { |
| 8 | if (!$edit.current && editor?.editor && editor?.state && editor?.view) { |
| 9 | // first time we got ref, similar to useEffect |
| 10 | console.log(editor); // do something with editor |
| 11 | $edit.current = editor; // store it |
| 12 | } |
| 13 | } |
| 14 | return ( |
| 15 | <div> |
| 16 | <CodeMirror |
| 17 | value={`console.log('hello')`} |
| 18 | theme="none" |
| 19 | ref={refCallack} |
| 20 | height="400px" |
| 21 | width="100%" |
| 22 | style={{ margin: '0 0 23px 0', flex: 1 }} |
| 23 | extensions={[langs.markdown()]} |
| 24 | /> |
| 25 | </div> |
| 26 | ); |
| 27 | } |
| 28 | |
| 29 | Component.displayName = 'PageExampleRef'; |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…