2017-12-28 10 views
2

私のプロジェクトでreact-highchartsを使用しています。私はチャートコンポーネントダイナミクスを生成し、ユーザーの選択に応じてその数を変更したいと思います。レンダリング中に間違いが表示されるのはなぜですか?

Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it. 

何の理由になります私は間違いを得るレンダリング中に

export default class ContentChartItem extends Component { 

    constructor(props) { 
     super(props); 
     this.state = { 
     } 

     this.config = {} 

    render() { 
     let { process_data } = this.props; 
     let config = this.config; 

     return (
      <div className="column"> 
       {typeof process_data == "undefined" ? " " 
        : 
        <div className="ui segment"> 
         {this.getChartItemsList} 
         <div className="ui button tiny fluid sidenav4"> 
          Info 
         </div> 
        </div> 
       } 
      </div> 
     ) 
    } 

    getChartItemsList =() => { 
     let config = this.config; 
     let { process_data } = this.props; 
     let chartContainers = []; 
     for (let i=0; i<process_data.length; i++) { 
      chartContainers.push(<ReactHighcharts config = {config}> </ReactHighcharts>) 
     } 

     return chartContainers; 
    }; 


} 

:私は、データを取得し、highchartsコンポーネントの配列を作成し、それらを返すコンポーネントと機能を書きましたか?そして私はそれをどのように解決できますか?ここで `)(`あなたが忘れてしまったので

{ 
    process_data && (
    <div className="ui segment"> 
    {this.getChartItemsList()} 
    <div className="ui button tiny fluid sidenav4"> 
     Info 
    </div> 
    </div> 
)} 
+4

:あなたはこの構文を使用して条件を行うことができますところで

{typeof process_data == "undefined" ? " " : <div className="ui segment"> {this.getChartItemsList()} <div className="ui button tiny fluid sidenav4"> Info </div> </div> } 

: '{this.getChartItemsListを( –

答えて

1

あなたが this.getChartItemsList()に電話をするのを忘れました)} `、そのメソッドを呼び出し、quesを閉じるように投票しました: '単純なTypo'。
関連する問題