MCPcopy
hub / github.com/graphql/graphiql / useSynchronizeValue

Function useSynchronizeValue

packages/graphiql-react/src/editor/hooks.ts:21–30  ·  view source on GitHub ↗
(
  editor: CodeMirrorEditor | null,
  value?: string,
)

Source from the content-addressed store, hash-verified

19import { CodeMirrorEditor } from './types';
20
21export function useSynchronizeValue(
22 editor: CodeMirrorEditor | null,
23 value?: string,
24) {
25 useEffect(() => {
26 if (editor && typeof value === 'string' && value !== editor.getValue()) {
27 editor.setValue(value);
28 }
29 }, [editor, value]);
30}
31
32export function useSynchronizeOption<K extends keyof EditorConfiguration>(
33 editor: CodeMirrorEditor | null,

Callers 1

EditorContextProviderFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected