For me, it was helpful to set a new state setState(EditorState.create({ ...state })) with the state returned from useCodemirror.
setState(EditorState.create({ ...state }))