Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新版本无法获取apis属性,来自样本例子 #443

Open
SeekPoint opened this issue Sep 19, 2022 · 0 comments
Open

新版本无法获取apis属性,来自样本例子 #443

SeekPoint opened this issue Sep 19, 2022 · 0 comments

Comments

@SeekPoint
Copy link

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 (



<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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant