Skip to content

Commit

Permalink
fix(types): rename AddChildren -> AddChildrenFunction, use type
Browse files Browse the repository at this point in the history
  • Loading branch information
bkrem committed May 12, 2023
1 parent cc88ad3 commit 8b3009e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/Node/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import React, { SyntheticEvent } from 'react';
import { HierarchyPointNode } from 'd3-hierarchy';
import { select } from 'd3-selection';
import { Orientation, Point, TreeNodeDatum, RawNodeDatum, RenderCustomNodeElementFn } from '../types/common.js';
import {
Orientation,
Point,
TreeNodeDatum,
RawNodeDatum,
RenderCustomNodeElementFn,
AddChildrenFunction,
} from '../types/common.js';
import DefaultNodeElement from './DefaultNodeElement.js';

type NodeEventHandler = (
Expand Down Expand Up @@ -165,7 +172,7 @@ export default class Node extends React.Component<NodeProps, NodeState> {
this.props.onNodeMouseOut(this.props.hierarchyPointNode, evt);
};

handleAddChildren = childrenData => {
handleAddChildren: AddChildrenFunction = childrenData => {
this.props.handleAddChildrenToNode(this.props.data.__rd3t.id, childrenData);
};

Expand Down
4 changes: 2 additions & 2 deletions src/types/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export type PathFunction = (link: TreeLinkDatum, orientation: Orientation) => st
export type PathClassFunction = PathFunction;

export type SyntheticEventHandler = (evt: SyntheticEvent) => void;
export type AddChildren = (children: RawNodeDatum[]) => void;
export type AddChildrenFunction = (children: RawNodeDatum[]) => void;

/**
* The properties that are passed to the user-defined `renderCustomNodeElement` render function.
Expand Down Expand Up @@ -70,7 +70,7 @@ export interface CustomNodeElementProps {
/**
* The `Node` class's internal `addChildren` handler.
*/
addChildren: AddChildren;
addChildren: AddChildrenFunction;
}

export type RenderCustomNodeElementFn = (rd3tNodeProps: CustomNodeElementProps) => JSX.Element;

0 comments on commit 8b3009e

Please sign in to comment.