reactjs - _rete.createEditor 不是函数,我的代码哪里有问题?
问题描述
我尝试在我的代码盒中实现 rete.js 可视化编程框架,并在我的 canvas.js 文件中使用以下代码:
import "../../styles.css";
import { createEditor } from "../../rete";
function Canvas() {
return (
<div className="App">
<div
style={{ width: "100vw", height: "100vh" }}
ref={ref => ref && createEditor(ref)}/>
</div>
);
}
export default Canvas;
浏览器显示以下错误消息:
rete.createEditor is not a function
ref
/src/components/layout/Canvas.js:10:40
7 | <div className="App">
8 | <div
9 | style={{ width: "100vw", height: "100vh" }}
> 10 | ref={ref => ref && createEditor(ref)}/>
| ^
11 | </div>
12 | );
13 | }
你能在这里找出我的错误吗?
解决方案
查看有关功能组件中 Ref 的反应文档 https://reactjs.org/docs/refs-and-the-dom.html#refs-and-function-components
推荐阅读
- angular - Angular 单元测试有什么问题吗
- php - 在 WooCommerce 结帐中更改特定产品的付款方式标题
- sql - 如何在 BigQuery 中的给定时间获取具有特定值作为其最新值的 id 数组?
- redux - 为什么 yield call(response.json) 挂起?
- python - 如何通过在 Django 中清除路径来转到主页
- python-sphinx - 列表项中的 Sphinx 文字块和 csv 表
- c++ - 从 C++17 中的迭代器范围复制分配给元组
- html - 有人可以从 Chrome 书签导出文件中的每个链接中解释 ICON 属性末尾的长字符串吗?
- python - 使用 numpy 数组(PLOTLY)对球形体积内的均匀分布的随机点进行采样
- capl - [CAPL]CANoe中如何将信号从一个CAN通道的PDU路由到另一个CAN通道?