Reactjs Cytoscape和react-Cytoscape.js-expand-collapse错误
嗨,我正在使用带有COSBilkent布局的react cytoscape,我还导入了cytoscape expand-collapse。当我点击折叠图标时,我收到错误:uncaughttypeerror:cy.undoRedo不是一个函数。有人知道为什么吗,下面是我的代码:Reactjs Cytoscape和react-Cytoscape.js-expand-collapse错误,reactjs,cytoscape.js,Reactjs,Cytoscape.js,嗨,我正在使用带有COSBilkent布局的react cytoscape,我还导入了cytoscape expand-collapse。当我点击折叠图标时,我收到错误:uncaughttypeerror:cy.undoRedo不是一个函数。有人知道为什么吗,下面是我的代码: import COSEBilkent from 'cytoscape-cose-bilkent'; import React, { useRef, useEffect, useState } from 'react'; i
import COSEBilkent from 'cytoscape-cose-bilkent';
import React, { useRef, useEffect, useState } from 'react';
import CytoscapeComponent from 'react-cytoscapejs';
import expandCollapse from 'cytoscape-expand-collapse';
import elements from './data';
expandCollapse(Cytoscape);
Cytoscape.use(COSEBilkent);
const Test = ({}) => {
const [cy, setCy] = useState(null);
useEffect(() => {
if (cy) {
cy.expandCollapse();
}
});
const layout = { name: 'cose-bilkent' };
return (
<CytoscapeComponent
cy={cy => {
setCy(cy);
}}
layout={layout}
elements={elements}
style={{ width: '600px', height: '600px' }}
/>
);
};
export default Test;
从“cytoscape cose bilkent”导入COSEBilkent;
从“React”导入React,{useRef,useffect,useState};
从“react cytoscapejs”导入CytoscapeComponent;
从“cytoscape expand collapse”导入expandCollapse;
从“./data”导入元素;
扩张性塌陷(细胞景观);
Cytoscape.use(COSEBilkent);
常量测试=({})=>{
const[cy,setCy]=useState(null);
useffect(()=>{
if(cy){
cy.expandCollapse();
}
});
常量布局={name:'cose bilkent'};
返回(
{
赛西(赛西);
}}
布局={layout}
元素={elements}
样式={{宽度:'600px',高度:'600px'}}
/>
);
};
导出默认测试;
您是否尝试导入撤消/重做?expand-collapse扩展有时使用Undo/Redo功能,即使是在(vanilla-cytoscape.js)[examples]()中。我建议您更改导入顺序,以尽量减少可能出现的错误。好的,我导入了,结果发现有两个版本的undo-redo;/您能告诉我“我建议您更改导入顺序以尽量减少可能的错误”是什么意思吗?我提供的链接显示了expand-collapse扩展的demo.html。您可以按照demo.html在头部导入依赖项的顺序导入依赖项(cytoscape react、cose bilkent、expand collapse等)。首先是cytoscape,然后是cose bilkent,然后是undo redo,最后是expand Collapse您是否尝试导入undo/redo?expand-collapse扩展有时使用Undo/Redo功能,即使是在(vanilla-cytoscape.js)[examples]()中。我建议您更改导入顺序,以尽量减少可能出现的错误。好的,我导入了,结果发现有两个版本的undo-redo;/您能告诉我“我建议您更改导入顺序以尽量减少可能的错误”是什么意思吗?我提供的链接显示了expand-collapse扩展的demo.html。您可以按照demo.html在头部导入依赖项的顺序导入依赖项(cytoscape react、cose bilkent、expand collapse等)。首先是细胞景观,然后是cose bilkent,然后是撤消重做,最后是扩展塌陷