2017-05-30 6 views
0

react-d3-componentsを使用してデータを表示したいですか?私はこれを実行しようとしました:React D3 Linechartコンポーネントの実装エラー

import React from 'react' 
import ChartState from './chart-state' 
import LineChart from 'react-d3-components' 

class ChartWidget extends React.Component { 
    constructor() { 
    super(...arguments) 
    this.state = new ChartState() 
} 

render() { 
    return (
    <Chart state={this.state} /> 
    ) 
    } 
} 

const Chart = observer (({ state, data }) => (
<div> 
    <LineChart 
     data={state.data} 
     width={400} 
     height={400} 
     margin={{top: 10, bottom: 50, left: 50, right: 10}}/> 
</div> 
)) 

export default ChartWidget 

が、これは動作しませんし、私はエラーReact.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in. Check the render method of

誰も私が間違っているのか知ってい. _class取得しますか?

+0

コードの最後に 'export default Chart'を追加しようとしましたか? – Sventies

+0

@SventenHaafはい、同じ問題がありました:-( – Steve

答えて

0

私は自分自身をそれを考え出し:

import { LineChart } from 'react-d3-components' 

は、ソリューションでした!

関連する問題