新版本无法获取apis属性,来自样本例子
- Dominant language
- TypeScript
- Stars
- 1.1k
- Forks
- 275
- PR merge metrics
- No merged PRs in 30d
Description
### 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
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";
// 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 (
{
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 (
{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_
Contributor guide
Assessment
This issue has not been assessed yet.