projectstorm / react-diagrams

a super simple, no-nonsense diagramming library written in react that just works
https://projectstorm.cloud/react-diagrams
MIT License
8.71k stars 1.18k forks source link

error on calling addPort() in cutsom node #645

Closed vickyvishal closed 4 years ago

vickyvishal commented 4 years ago

My error

Annotation 2020-05-24 211518

my nodeModel

image my portModel

image

renato-bohler commented 4 years ago

Do you have the code for the Widget as well?

vickyvishal commented 4 years ago

I did not have the port widget in the model. My bad :/ . After adding there is this type error.

image

console.log(this.props.node.getPort(PortModelAlignment.LEFT)) -> undefined(2)

My modelWidget

image

renato-bohler commented 4 years ago

Hmmm shoudn't the PortWidget have been created with PortModelAlignment.BOTTOM instead of LEFT?

vickyvishal commented 4 years ago

Hmmm shoudn't the PortWidget have been created with PortModelAlignment.BOTTOM instead of LEFT?

image

renato-bohler commented 4 years ago

Hmmmmm, and what is this.props.node.getPort(PortModelAlignment.BOTTOM) returning? Can you log it?

vickyvishal commented 4 years ago

Here is the log for this.props.node.getPort(PortModelAlignment.BOTTOM) image

image

renato-bohler commented 4 years ago

That's odd... I'm not sure what TypeScript is complaining about here :frowning_face:

vickyvishal commented 4 years ago

Strange but I made it work by making "strict": false in tsconfig.json . I don't know why it is working. Also can't see any type error on my IDE now :(

ferrantedev commented 4 years ago

try with port={this.props.node.getPort(PortModelAlignment.Bottom) as YourPortModelClassHere}

for instance if you are using DefaultPortModel, then port={this.props.node.getPort(PortModelAlignment.Bottom) as DefaultPortModel}