1

I want to build dynamic trees in a React application and I am using the D3 library with external sources (CSV file) for that.

This CSV file updates dynamically, the problem is that this file is located inside the React source folder, so every time the file changes, the whole application reloads. I only want the tree to reload with it because I lose every other entered information upon reload.

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));
}

Can someone help me?

M0nst3R
  • 5,186
  • 1
  • 23
  • 36
Hkni
  • 115
  • 1
  • 11
  • You should configure Webpack to ignore this CSV file from the files it watches for reloading the application (I'm assuming you're using Webpack). Another alternative is to use a server and store this data on the server side. – M0nst3R Aug 10 '20 at 15:20
  • See if this [question](https://stackoverflow.com/questions/44376589/webpack-exclude-a-specific-file) helps you. – M0nst3R Aug 10 '20 at 15:21
  • Thank you for your answer, I wasn't using wepback when I saw ur answer I had installed it but things get missed up. Do I need it if I cant go with the second alternative? – Hkni Aug 11 '20 at 07:34
  • I am using flask with python, it wont be possible to store the csv file in the folder of flask and then fetch it with a flask API ? – Hkni Aug 11 '20 at 07:55
  • If you didn't already use it, there is no need to install it. I would suggest storing the data on the server side. It won't be a file anymore, you can use a simple relational database with a set of APIs to get, update, and delete the data. – M0nst3R Aug 11 '20 at 07:57

0 Answers0