react-arborist icon indicating copy to clipboard operation
react-arborist copied to clipboard

Property 'select' does not exist on type 'never'

Open aleksbobic opened this issue 1 year ago • 1 comments
trafficstars

Hi first of all thanks for a fantastic component!

I have a problem with the type definitions when using the useRef example.

So the following code bellow produces the error Property 'select' does not exist on type 'never' on the tree.select statement. I tried defining the tree component type but couldn't figure out what it is.

function App() {
    const treeRef = useRef();

    useEffect(() => {
        const tree = treeRef.current;
        if (tree) {
            tree.select("1");
        }
  }, []);

  return <Tree initialData={data} ref={treeRef} />;
}

aleksbobic avatar Jan 21 '24 19:01 aleksbobic

Aww man, that's annoying. @ts-ignore 🙊

What version of TS are you running?

jameskerr avatar Feb 07 '24 17:02 jameskerr

Try useRef<TreeApi<T> | undefined> where T is the type of the data being supplied to the Tree component's data property.

mgoshorn avatar Sep 05 '25 03:09 mgoshorn