lundi 26 juin 2017

react test import deeply nested components

I have a React app. The folders looks like this:

├── src
│   ├── App.jsx
│   └── components
│       ├── charts
│       │   ├── Chart.jsx
│       └── editor
│           └── Editor.jsx
│
├── test
│   └── testComponents
│       ├── testCharts
│       │   └── testChart.js
│       └── testEditor
│           └── testEditor.js
│
├── package.json
└── webpack.config.js

Because the folders are deep, the import inside testChart.js looks like:

import Chart from './../../../src/components/charts/Chart.jsx'

// ...codes...

The ./../../../src/ ... is not very friendly I think. Is there any way to make it more clean like import charts/Charts.jsx?

Thanks for your time!

Aucun commentaire:

Enregistrer un commentaire