2017-10-10 3 views
0

저는 Chartist 라이브러리를 사용하는 차트에 대한 상용구 코드를 사용하고 있습니다. 유일한 절도 내가 수업 전에 수출을 추가한다는 것입니다 :반출 중 반출 클래스

import React from 'react'; 
import ReactDOM from 'react-dom'; 
import ChartistGraph from '../index'; 

export class Pie extends React.Component { 
    render() { 

    var data = { 
     labels: ['W1', 'W2', 'W3', 'W4', 'W5', 'W6', 'W7', 'W8', 'W9', 'W10'], 
     series: [ 
     [1, 2, 4, 8, 6, -2, -1, -4, -6, -2] 
     ] 
    }; 

    var options = { 
     high: 10, 
     low: -10, 
     axisX: { 
     labelInterpolationFnc: function(value, index) { 
      return index % 2 === 0 ? value : null; 
     } 
     } 
    }; 

    var type = 'Bar' 

    return (
    <div> 
     <ChartistGraph data={data} options={options} type={type} /> 
    </div> 
    ) 
} 
} 

내가 사용하여 내 부모 구성 요소에서 구성 요소를 가져 오려고 :

import {Pie} from '../components/dashboardChart'; 

내가받을 다음과 같은 오류 :

54:28-41 "export 'default' (imported as 'ChartistGraph') was not found in '../index'

어떤 아이디어가 원인입니까?

+1

은 사용에 반대하고 있습니까과 같이 할 수있는'수출 기본 파이 React.Component'를 확장? – Andrew

답변

0

당신은 export default class Pie extends React.Component {}

당신에게 파이 클래스를 내보낼 수 있습니다 그리고 당신이 그것을 가져올 때이 import Pie from '../components/dashboardChart';

+0

의견을 주셔서 감사합니다. 그러나 제안을 사용하여 코드를 변경하면 54 : 28-41 "기본적으로 내보내기"('ChartistGraph'로 가져 오기)가 '../index'에서 찾을 수 없습니다. 가져 오기 명령문 : ChartistGraph from '../index'; – user3642173

+0

몇 가지를 변경했는데 이제이 오류가 발생합니다 : 모듈을 찾을 수 없습니다 : '/ Users/username/react/project/node_modules/react-chartist/dist – user3642173