首页 > 解决方案 > 在反应中创建动态树

问题描述

我想在 React 应用程序中构建动态树,为此我正在使用带有外部源(CSV 文件)的D3库。

这个 CSV 文件是动态更新的,问题是这个文件位于 React 源文件夹中,所以每次文件更改时,整个应用程序都会重新加载。我只希望树重新加载它,因为我在重新加载时丢失了所有其他输入的信息。

componentWillMount() {
    treeUtil.parseCSV(csvSource)
    .then((data) => {
        this.setState({ data });
        console.log('This is the new data for the tree', data);
    })
    .catch((err) => console.error(err));
}

有人能帮我吗?

标签: reactjsreact-d3

解决方案


推荐阅读