You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Uncaught TypeError: Cannot read properties of undefined (reading 'getInfo')
at LayoutSelector (layout-selector.js:14:1)
at renderWithHooks (react-dom.development.js:16305:1)
at mountIndeterminateComponent (react-dom.development.js:20074:1)**
at:
index.js
import React from "react";
import ReactDOM from "react-dom";
import Graphin, { Utils } from "@antv/graphin";
import { Toolbar } from "@antv/graphin-components";
import LayoutSelector from "./layout-selector.js";
Describe the bug
https://codesandbox.io/s/oplx5
update version to:
"dependencies": {
"@ant-design/compatible": "^1.1.2",
"@antv/graphin": "2.7.10",
"@antv/graphin-components": "2.4.0",
"antd": "4.23.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-scripts": "4.0.3"
},
"devDependencies": {
"typescript": "4.8.3"
},
**we can see:
layout-selector.js:14
at:
index.js
import React from "react";
import ReactDOM from "react-dom";
import Graphin, { Utils } from "@antv/graphin";
import { Toolbar } from "@antv/graphin-components";
import LayoutSelector from "./layout-selector.js";
// import "@antv/graphin/dist/index.css";
import "@antv/graphin-components/dist/index.css";
import "./styles.css";
const data = Utils.mock(10)
.random(0.6)
.graphin();
const App = () => {
const [layout, changeLayout] = React.useState({ name: "force", options: {} });
console.log('---yk---layout is:', layout);
console.log('---yk---changeLayout is:', changeLayout);
return (
<LayoutSelector
value={layout.name}
onChange={value => {
changeLayout({
...layout,
name: value
});
}
}
/>
);
};
const rootElement = document.getElementById("root");
ReactDOM.render(, rootElement);
layout-selector.js:
import React from "react";
import { Select } from "antd";
// https://stackoverflow.com/questions/60687863/attempted-import-error-icon-is-not-exported-from-antd
import Icon from '@ant-design/icons'; // v4
//import {Icon} from 'antd';
import "antd/dist/antd.css";
const SelectOption = Select.Option;
const LayoutSelector = (props) => {
const { apis, value, onChange } = props;
console.log('---yk---props:', props);
console.log('---yk---apis:', apis);
// 包裹在graphin内部的组件,将获得graphin提供的额外props
const { layouts } = apis.getInfo();
return (
<div style={{ position: "absolute", top: 10, left: 10 }}>
<Select style={{ width: "120px" }} value={value} onChange={onChange}>
{layouts.map(item => {
const { name, icon, disabled, desc } = item;
return (
{desc}
);
})}
);
};
export default LayoutSelector;
Your Example Website or App
no
Steps to Reproduce the Bug or Issue
https://codesandbox.io/s/oplx5
update version to:
"dependencies": {
"@ant-design/compatible": "^1.1.2",
"@antv/graphin": "2.7.10",
"@antv/graphin-components": "2.4.0",
"antd": "4.23.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-scripts": "4.0.3"
},
"devDependencies": {
"typescript": "4.8.3"
},
Expected behavior
na
Screenshots or Videos
No response
Platform
https://codesandbox.io/s/oplx5
update version to:
"dependencies": {
"@ant-design/compatible": "^1.1.2",
"@antv/graphin": "2.7.10",
"@antv/graphin-components": "2.4.0",
"antd": "4.23.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-scripts": "4.0.3"
},
"devDependencies": {
"typescript": "4.8.3"
},
Additional context
No response
The text was updated successfully, but these errors were encountered: