Search code examples
reactjscsvstorybook

react storybook load csv file


I have a quick question regarding how to load a static file in React storybook framework. Currently, I created a storybook by following the instruction in create-react-app.

Now, I am trying to load a csv file containing some data to visualize. For this, I placed the csv file under public folder by following the instruction here.

However, I couldn't load the file. Any suggestions?


Solution

  • The default webpack config storybook provides would not allow importing csv files; it only supports media files like images in the example.

    What you'll want to do is add this custom loader, dsv-loader, to your storybook webpack config using Extend Mode. You will then be able to import the csv data as a javascript object.