react-sortable-tree icon indicating copy to clipboard operation
react-sortable-tree copied to clipboard

Unable to find node on an unmounted component.

Open maifeeulasad opened this issue 6 years ago • 13 comments

Reporting a Bug?

import React from 'react';
import SortableTree from 'react-sortable-tree';
import 'react-sortable-tree/style.css';

class App extends React.Component{

    state = {
        treeData: [
            { title: 'Chicken', children: [{ title: 'Egg' }] },
            { title: 'Fish', children: [{ title: 'fingerline' }] },
        ],
    };
    

    render() {
        return(
            <div>
                <SortableTree
                    treeData={this.state.treeData}
                />
            </div>
        )
    }
}

export default App;

maifeeulasad avatar Nov 04 '20 14:11 maifeeulasad

It's an issue when you use the latest version of React. Try downgrading to '16.11.0' for example.

GlennSmeulders avatar Nov 04 '20 16:11 GlennSmeulders

@GlennSmeulders I've tried that too. Here is my sandbox.io : https://codesandbox.io/s/react-tree-test-9p78y

I have even tried in my local machine too, it doesn't work.

Added onChnage(data) and even removed StrictMode for testing purpose.

maifeeulasad avatar Nov 04 '20 17:11 maifeeulasad

I had the same issue after updating to the react 17. Downgrading react and react-dom to 16.14.0 solved it temporarely

JustynaKK avatar Nov 05 '20 10:11 JustynaKK

@JustynaKK can I have tried both on 16.11 and 16.14, still the problem doesn't get resolved, you can check my sandbox . If anyone can help it will be really helpful to me a lot.

I have invited you on Hangout too, so we can discuss it.

maifeeulasad avatar Nov 05 '20 14:11 maifeeulasad

@maifeeulasad I've tried your example and noticed that you didn't specify the div height that you wrapped your sortable tree component in. If I set the div height your example works for me.

Example: https://codesandbox.io/s/react-tree-test-forked-zjw1w

GlennSmeulders avatar Nov 05 '20 15:11 GlennSmeulders

@GlennSmeulders thanks a lot. One last question can I make this not editable and all items expanded based on some condition ?

maifeeulasad avatar Nov 05 '20 15:11 maifeeulasad

@maifeeulasad You can set 'canDrag' to false to prevent dragging. All TreeItem's have a property 'expanded', you can use your condition here.

GlennSmeulders avatar Nov 05 '20 15:11 GlennSmeulders

@GlennSmeulders thanks a lot.

maifeeulasad avatar Nov 05 '20 15:11 maifeeulasad

As noted https://github.com/frontend-collective/react-sortable-tree/issues/830#issuecomment-722396912

Downgrading to:

    "react": "16.14",
    "react-dom": "16.14",
    "react-scripts": "4.0.0",
    "react-sortable-tree": "^2.8.0",

Resolved this issue for me.

OR13 avatar Nov 07 '20 14:11 OR13

Just set onChange={(treeData) => setItems([...treeData])} isVirtualized={false}

ArashArzandeh avatar Jun 05 '21 17:06 ArashArzandeh

Just set onChange={(treeData) => setItems([...treeData])} isVirtualized={false}

worked, thanks

qafoori avatar Sep 10 '21 20:09 qafoori

Just set onChange={(treeData) => setItems([...treeData])} isVirtualized={false}

It worked in latest version, thanks

chira37 avatar Sep 11 '21 15:09 chira37

Just set onChange={(treeData) => setItems([...treeData])} isVirtualized={false}

This worked, thanks!

armankarimi avatar Mar 02 '22 19:03 armankarimi