小编Ala*_*nry的帖子

错误:函数组件不能有字符串引用。我们建议使用 useRef() 代替

我在我的 React 应用程序中使用 ace Editor 并收到上述错误。我想通过提交按钮触发的函数调用将我在 React 应用程序中使用的 Ace Editor IDE 的内容放入其中。

<AceEditor
ref='aceEditor'
height='100%'
width='100%'
mode={ideLanguage}
theme={ideTheme}
fontSize={ideFontSize}
showGutter={true}
showPrintMargin={false}/>
Run Code Online (Sandbox Code Playgroud)

这是按钮

<Button
type='button'
buttonStyle='btn--primary--normal'
buttonSize='btn--medium'
onClick={SendCode}
>SUBMIT</Button>
Run Code Online (Sandbox Code Playgroud)

这就是函数

const SendCode = () => {
  console.log(this.refs.aceEditor.editor.getValue());
};
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么??

javascript web-deployment ace-editor reactjs

5
推荐指数
1
解决办法
3万
查看次数

标签 统计

ace-editor ×1

javascript ×1

reactjs ×1

web-deployment ×1