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

Tutorial not working #1004

Open
johnsmithlon opened this issue May 20, 2023 · 1 comment
Open

Tutorial not working #1004

johnsmithlon opened this issue May 20, 2023 · 1 comment

Comments

@johnsmithlon
Copy link

johnsmithlon commented May 20, 2023

I am trying to follow:

https://projectstorm.gitbook.io/react-diagrams/getting-started/using-the-library

I created a new typescript react project using:

npx create-react-app my-app --template typescript

Then I put the code from the tutorial into index.tsx. i.e.

import createEngine, {
DefaultLinkModel,
DefaultNodeModel,
DiagramModel
} from '@projectstorm/react-diagrams';

import {
CanvasWidget
} from '@projectstorm/react-canvas-core';

// create an instance of the engine with all the defaults
const engine = createEngine();

// node 1
const node1 = new DefaultNodeModel({
name: 'Node 1',
color: 'rgb(0,192,255)',
});
node1.setPosition(100, 100);
let port1 = node1.addOutPort('Out');

// node 2
const node2 = new DefaultNodeModel({
name: 'Node 1',
color: 'rgb(0,192,255)',
});
node2.setPosition(100, 100);
let port2 = node2.addOutPort('Out');

// link them and add a label to the link
const link = port1.link(port2);
link.addLabel('Hello World!');

const model = new DiagramModel();
model.addAll(node1, node2, link);
engine.setModel(model);

This gives the following error:

TS2786: 'CanvasWidget' cannot be used as a JSX component.
Its instance type 'CanvasWidget' is not a valid JSX element.
Type 'CanvasWidget' is missing the following properties from type 'ElementClass': context, setState, forceUpdate, props, and 2 more.
38 |
39 |

40 |

Can you suggest what I am doing wrong?

@LynchyC
Copy link
Contributor

LynchyC commented Jul 9, 2023

I don't see the use of CanvasWidget anywhere apart from the import statement.

I would recommend using the demo code as a basis and see if the problem still persists for you.

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

2 participants