#TypeScript: Custom NodeTypes

1 messages · Page 1 of 1 (latest)

dreamy timber
#

While building out my custom node type I have followed the documentation at https://reactflow.dev/docs/api/nodes/custom-nodes/. But when I pass in my memoized object of node types I get a TS Error about mismatch on types.

Any pointers would be much appreciated on how to resolve this.

If you want to add new node types, you need to pass a nodeTypes object to the ReactFlow component:

celest maple
#

The type is called "NodeTypes"

#

So const nodeTypes: NodeTypes = useMemo(.. should do it

dreamy timber
#

Ok, this ended up being fixed by me changing my Node signature to ..

function TopicNode({id, data}) : NodeProps<any> {...}
celest maple
#

That's the better way 🙂

dreamy timber
#

Is there a way to send a PR in to the docs?

celest maple
#

sure thing! You find an edit button on the bottom left of every page.

dreamy timber
#

ok. cool. Are y'all good with inline references to "typing"?

#

or do you want it all on one page?

celest maple
#

good question

#

the docs lack of TS refs

#

We will revise the docs and add more TS infos on the separate pages

dreamy timber
#

ok. 🙂

celest maple
#

thanks!

dreamy timber
near oracle
#

When iam adding a node with type = 'input', is there any way that i can also customize it ? here i dont want to change node type from input.

celest maple
#

@near oracle better start a new thread. It’s possible. You can overwrite the type.