Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript js草稿中的RichUtils.handleKeyCommand错误:this.props.editorState.isInCompositionMode不是函数错误_Javascript_Reactjs_Draftjs - Fatal编程技术网

Javascript js草稿中的RichUtils.handleKeyCommand错误:this.props.editorState.isInCompositionMode不是函数错误

Javascript js草稿中的RichUtils.handleKeyCommand错误:this.props.editorState.isInCompositionMode不是函数错误,javascript,reactjs,draftjs,Javascript,Reactjs,Draftjs,我使用的是Draft Js,在尝试使用RichUtils的handleKeyCommand时,应用程序停止,我得到一个错误:“this.props.editorState.isInCompositionMode不是函数错误” 有人能帮忙吗 谢谢 const MyEditor = () => { const [editorState, setEditorState] = useState(()=>EditorState.createEmpty()) const editor

我使用的是Draft Js,在尝试使用RichUtils的handleKeyCommand时,应用程序停止,我得到一个错误:“this.props.editorState.isInCompositionMode不是函数错误”

有人能帮忙吗

谢谢

const MyEditor = () => {

  const [editorState, setEditorState] = useState(()=>EditorState.createEmpty())
  const editor = useRef(null)

  useEffect(() => {focus()}, [])

  const onChange = (editorState) => setEditorState({ editorState });
  const focus = () => editor.current.focus()

  const handleKeyCommand = (command, editorState) => {
    const newState = RichUtils.handleKeyCommand(editorState, command)
    debugger;
    if (newState) {
      onChange(newState);
      return 'handled';
    }
    return 'not-handled';
  }

  return (
    <div className="editor" onClick={focus}>
      <Editor
        editorState={editorState}
        handleKeyCommand={handleKeyCommand}
        onChange={setEditorState}
        ref={editor}
        placeholder="Tell your story"
        spellCheck
      />
    </div>
  );
}

export default MyEditor
constmyeditor=()=>{
常量[editorState,setEditorState]=useState(()=>editorState.createEmpty())
常量编辑器=useRef(null)
useEffect(()=>{focus()},[]))
const onChange=(editorState)=>setEditorState({editorState});
const focus=()=>editor.current.focus()
const handleKeyCommand=(命令,编辑器状态)=>{
const newState=RichUtils.handleKeyCommand(editorState,command)
调试器;
如果(新闻状态){
onChange(新闻状态);
返回“已处理”;
}
返回“未处理”;
}
返回(
);
}
导出默认MyEditor