Open
Description
Describe the bug
Type definition for ports doesn't extends React.DetailedReactHTMLElement
which makes createSchema
throw error
To Reproduce
import { createSchema } from "beautiful-react-diagrams";
import React from "react";
const CustomNode = (props: {
inputs?: React.DetailedReactHTMLElement<any, any>[];
}) => {
const { inputs } = props;
return (
<div style={{ background: "#717EC3", borderRadius: "10px" }}>
<div style={{ padding: "10px", color: "white" }}>Custom Node</div>
<div style={{ marginTop: "20px" }}>
{inputs?.map((port) =>
React.cloneElement(port, {
style: { width: "50px", height: "25px", background: "#1B263B" }
})
)}
</div>
</div>
);
};
createSchema({
nodes: [
{
id: "node-1",
content: "Node 1",
coordinates: [150, 60],
outputs: [{ id: "port-1", alignment: "right" }]
},
{
id: "node-custom",
coordinates: [250, 60],
render: CustomNode, // <-- ERROR
inputs: [{ id: "custom-port-1", alignment: "left" }]
}
]
});
Expected behavior
not to throw error
Additional context
live preview:
https://codesandbox.io/s/beautiful-react-diagram-ts-error-vxw5h
Metadata
Assignees
Labels
No labels
Activity