簡體   English   中英

React-警告:React.createElement:類型不能為null,undefined,boolean或number

[英]React - Warning: React.createElement: type should not be null, undefined, boolean, or number

我正在嘗試在我的項目中實施此圖表

Codepen

在我的React應用程序中,我創建了一個稱為ChartsGrid的組件,在其中我LineChart from './d3/LineChart'導入LineChart from './d3/LineChart'及其子組件HorizontalAxisVerticalAxisLinePlot

data狀態正確構建,我在控制台中看到了

import React from 'react';
import Chart from './Chart';
import LineChart from './d3/LineChart';

export default class ChartsGrid extends React.Component{

  render() {

    const view = [480, 320];
    const trbl = [0, 0, 0, 0]
    const horizontalAxisHeight = 30;
    const verticalAxisWidth = 42;
    const { data } = this.props;

    return (
      <div className="grid">
          <LineChart {...{view, trbl, data, horizontalAxisHeight, verticalAxisWidth}} />
      </div>
    )
  }
};

我在控制台中收到此錯誤

在此處輸入圖片說明

它抱怨我在ChartsGrid渲染方法,我不太了解可能出什么問題。 所有設置對我來說似乎都不錯,在上一個Codepen示例中 ,唯一的區別是它正在setTimeout函數中渲染線形圖數據。

我在做什么潛在的錯誤?

添加console.log('!!!!', LineChart)並查看是否已定義。 也許您在導入/導出時出錯

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM