improve types

This commit is contained in:
AykutSarac 2022-09-03 19:39:28 +03:00
parent 1f477e99d9
commit 897ceabfe0
2 changed files with 9 additions and 3 deletions

View File

@ -24,7 +24,7 @@ export const CustomNode = (nodeProps: NodeProps) => {
return (
<Node {...nodeProps} label={<Label style={baseLabelStyle} />}>
{({ width, height, x, y, node }) => {
if (properties.text instanceof Object) {
if (Array.isArray(properties.text)) {
return (
<ObjectNode
value={properties.text}
@ -38,7 +38,7 @@ export const CustomNode = (nodeProps: NodeProps) => {
return (
<TextNode
node={node}
node={node as NodeData}
isParent={properties.data.isParent}
value={properties.text}
width={width}

8
src/types.d.ts vendored
View File

@ -1,4 +1,10 @@
type CanvasDirection = "LEFT" | "RIGHT" | "DOWN" | "UP"
type CanvasDirection = "LEFT" | "RIGHT" | "DOWN" | "UP";
interface CustomNodeData {
isParent: true;
hasChild: !!children.length;
children;
}
interface NodeData<T = any> {
id: string;