0

I have created a new React project with command npx create-react-app my-app and installed the package chart-race-react with npm install --save chart-race-react but when I run npm start i get the error: 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 = {

this is my code:

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;
Amrouane
  • 143
  • 3
  • 16

0 Answers0