TypeError: Невозможно прочитать свойство 'height' из undefined при использовании Chart-Race-React - PullRequest
0 голосов
/ 20 января 2020

Я создал новый проект React с командой npx create-react-app my-app и установил пакет chart-race-react с npm install --save chart-race-react, но когда я запускаю npm start, я получаю ошибку: TypeError: Cannot read property 'height' of undefined:

  13 | class BarChart extends React.Component {
  14 |     constructor(props){
  15 |         super(props);
> 16 |         this.barHeight = `calc(${props.barStyle.height} + ${props.barStyle.marginTop})`;
  17 |         this.nItmes = Object.keys(this.props.data).length;
  18 |         this.maxItems = props.maxItems <= this.nItmes ? props.maxItems : this.nItmes;
  19 |         this.barChartStyle = {

это мой код:

import React from 'react';
import logo from './logo.svg';
import BarChart from 'chart-race-react';

import './App.css';

function App() {
  return (
    <div className="App">
      <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />
        <p>
          Edit <code>src/App.js</code> and save to reload, okay?.
        </p>
        <div style={{width: "500px"}}>
          <BarChart />
        </div>
        <a
          className="App-link"
          href="https://reactjs.org"
          target="_blank"
          rel="noopener noreferrer"
        >
          Learn React
        </a>
      </header>
    </div>
  );
}

export default App;
...