File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
packages/compass-crud/src/components Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -81,16 +81,20 @@ const JSONEditor: React.FunctionComponent<JSONEditorProps> = ({
8181 ) ;
8282 const [ initialValue ] = useState < string > ( ( ) => doc . toEJSON ( ) ) ;
8383 const [ containsErrors , setContainsErrors ] = useState < boolean > ( false ) ;
84+ const setModifiedEJSONStringRef = useRef < ( value : string | null ) => void > (
85+ doc . setModifiedEJSONString . bind ( doc )
86+ ) ;
8487
8588 useEffect ( ( ) => {
89+ const setModifiedEJSONString = setModifiedEJSONStringRef . current ;
8690 return ( ) => {
8791 // When this component is used in virtualized list, the editor is
8892 // unmounted on scroll and if the user is editing the document, the
8993 // editor value is lost. This is a way to keep track of the editor
9094 // value when the it's unmounted and is restored on next mount.
91- doc . setModifiedEJSONString ( editing ? value : null ) ;
95+ setModifiedEJSONString ( editing ? value : null ) ;
9296 } ;
93- } , [ value , editing , doc ] ) ;
97+ } , [ value , editing ] ) ;
9498
9599 const handleCopy = useCallback ( ( ) => {
96100 copyToClipboard ?.( doc ) ;
You can’t perform that action at this time.
0 commit comments