Search code examples
typescriptreact-component

TypeScript complaining that rc-tree Tree doesn't have a treeData prop


In my react component has the following code from react-component/tree,

import Tree from 'rc-tree';
...
<Tree
    className="treeThingy"
    treeData={myTreeData}
/>

This works, but typescript is complaining that the treeData props doesn't exsist on Tree with the following,

Property 'treeData' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly & Readonly<{ children?: ReactNode; }>'.ts(2322)

Is this a problem with my code, the rc-tree code, or something else?


Solution

  • Seems more an issue with @types/rc-tree type declarations, not the library. TreeProps is missing the treeData props, but the library has it.

    From the version 3, it seems that react-component/tree will include types in the package itself, without relaying on the DefinitelyTyped package.