title: How to map multiple charts with chart.js in react
body: <p>I am able to render each chart separately but I have no idea how to render multiple charts at the same time. Here is my code:</p>
  
  <pre><code>import React, { Component } from "react";
  import {Line} from 'react-chartjs-2';
  
  import axios from 'axios';
  
  class Chart extends Component {
      constructor(props) {
          super(props);
          this.state = {
             chartData: {},
             data: []
        }
      }
  
      componentDidMount() {
          axios.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&amp;order=market_cap_desc&amp;per_page=2&amp;page=1&amp;sparkline=true')
  
          .then(res =&gt; {
  
              const x = res.data;
              let y = [];
              x.forEach(element =&gt; {
                  y.push(element.sparkline_in_7d.price)
              })
  
               console.log(y);
  
              this.setState({ 
  
                      chartData: {
                          labels: y,
                          datasets:[{
                              data: y,
                          }
                       ]
                      },
                      data: y
  
              })
          })
      }
  
  
      render() {
          return (
              &lt;div className="chart"&gt;
  
  
           //*WORKS*
                {/* {this.state.data.map((n, index) =&gt; {
                                 return (
                                  &lt;li key={index}&gt;{n}&lt;/li&gt;
                              );
                  })} */}
  
  
         //*DOES NOT WORK*
                 {this.state.chartData.map((n, index) =&gt; {
                                 return (
  
                                  &lt;Line key={index} data={n}/&gt;
                              );
                  })} 
  
  
  
              &lt;/div&gt;
          );
      }
  }
  
  export default (Chart);
  </code></pre>
  
  <p>Normally I don't have any issues mapping data but I am having issues doing so with chartjs as when I try this it says it is not a function. Any help here would be appreciated.</p>