Skip to content

Tutorial not working #1004

Open
Open
@johnsmithlon

Description

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions