antonioru / antonioru/beautiful-react-diagrams

Typescript with custom Nodes

オープン
#133 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
2.7k
フォーク
171
PR マージ指標
30日以内にマージされた PR はありません

説明

**Describe the bug**
Type definition for ports doesn't extends `React.DetailedReactHTMLElement` which makes `createSchema` throw error

**To Reproduce**
```typescript
import { createSchema } from "beautiful-react-diagrams";
import React from "react";

const CustomNode = (props: {
inputs?: React.DetailedReactHTMLElement[];
}) => {
const { inputs } = props;

return (


Custom Node


{inputs?.map((port) =>
React.cloneElement(port, {
style: { width: "50px", height: "25px", background: "#1B263B" }
})
)}


);
};

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

**Screenshots**
image

**Additional context**
live preview:
https://codesandbox.io/s/beautiful-react-diagram-ts-error-vxw5h

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。