score:0

if you are using hooks and usestate, ensure that the url is a string and not resolved as an object before using the data.

before input

before output

after input

after output

score:1

i had the same issue and here's how i solved it. check if the data is in the same directory as the index.html file. in my case, my index.html file is in the public/ folder, so i created public/data/data.csv. you can then try d3.csv('./data/data', function(data){...}) to read in the data.

score:3

you could try using the import statement to load the csv file at first. :)

import react from 'react';
import * as d3 from 'd3';
import data from "./data/data.csv";

class list extends react.component{
  componentdidmount(){
    d3.csv(data).then(function(d, error){
      if (error) {
        console.log(error);
      } else {
        console.log(d);
      };
    });
  }

  render(){
    return(
      <div> </div>
    );
  }
} 

export default list;

Related Query

More Query from same tag