Chartjs-Adding condition in ComponentDidMount to display chart data

0👍

There are two errors in your code.

  1. Your have to end the variable declaration with ; instead of ,
  2. You have to declare datacheck outside the if else block unless you want it undefined
    componentDidMount() {
                ...
                let dataCheck;
                if(this.props.data2){
                     dataCheck = {
                       ...
                    }
                }
                else {
                    dataCheck = {
                      ...
                    }
        }
    }

Leave a comment