Disappearing cursor in code mirror editor

Hi,

I am facing issue with cursor in the code mirror editor when I press any key. The cursor disappears and need a mouse click to make it reappear.

Below is the code snippet from React application-
const [editorCode, setEditorCodeValue] = useState(‘’);

<CodeMirror
value={editorCode}
width=“700px”
height=“200px”
theme={myTheme}
caret-color=“red”
onChange={(code,e) =>

                 setEditorCodeValue(code)                     
              }
              extensions={[javascript({ jsx: true })]}
              />

The issue occurs only when I add setEditorCodeValue(code) to the onChange event.
Any assistance on this issue would really help.

Thanks.
Deepa