vasturiano / react-force-graph

React component for 2D, 3D, VR and AR force directed graphs
https://vasturiano.github.io/react-force-graph/example/large-graph/
MIT License
2.19k stars 282 forks source link

Typescript fails on extraRenderers #317

Open joelnz opened 3 years ago

joelnz commented 3 years ago

Having the extraRenderers prop gives Typescript error.

`Failed to compile.

/Users/imac/Desktop/ui/src/DirectoryGrid.tsx TypeScript error in /Users/imac/Desktop/ui/src/DirectoryGrid.tsx(276,9): Type '{ width: number; height: number; enableNodeDrag: false; onNodeClick: (node: any) => void; extraRenderers: CSS2DRenderer[]; graphData: { nodes: any[]; links: any[]; }; backgroundColor: any; ... 10 more ...; nodeThreeObjectExtend: true; }' is not assignable to type 'IntrinsicAttributes & ForceGraphProps & { ref?: MutableRefObject<ForceGraphMethods | undefined> | undefined; } & { ...; }'. Property 'extraRenderers' does not exist on type 'IntrinsicAttributes & ForceGraphProps & { ref?: MutableRefObject<ForceGraphMethods | undefined> | undefined; } & { ...; }'. TS2322

   enableNodeDrag={false}
 onNodeClick={handleClick}
    extraRenderers={extraRenderers}
   ^
    graphData={data}
    backgroundColor={datStyling.bgcolor3}
  d3AlphaMin={datStyling.d3AlphaMin}`

A temporarily fixed it by ignoring typescript for this line

// @ts-ignore: Unreachable code error extraRenderers={extraRenderers}

vasturiano commented 3 years ago

@joelnz thanks for reaching out.

It's not clear why you're experiencing this issue. The extraRenderers prop should be declared in the TS definitions for react-force-graph-3d. Would you mind making a simplified example on codesandbox that reproduces this problem.

Also, can you confirm this is relative to the react-force-graph-3d module? It's not clear from your message. That's the only module that has this prop.