MCPcopy Create free account
hub / github.com/uiwjs/react-codemirror / Component

Function Component

www/src/pages/examples/ExampleRef.tsx:5–27  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import { useRef } from 'react';
4
5export 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
29Component.displayName = 'PageExampleRef';

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…