Swizz 6ix
Swizz 6ix

Reputation: 23

i am trying to format numbers using the react numeral packages, but i am getting the error (Numeral cannot be invoked without 'new')

import React from "react";
import numeral from "react-numeral";
import {Circle, Popup} from "react-leaflet";


export const showDataOnMap = (data, casesType = "cases") => (
  data.map((country) => (
    <Circle>
      center = {[country.countryInfo.lat, country.countryInfo.long]}

      fillOpacity = {0.4},
      color={casesTypeColors[casesType].hex},
      fillColor={casesTypeColors[casesType].hex},

      radius={
      Math.sqrt(country[casesType]) * casesTypeColors[casesType].multiplier
    }
      <Popup>
        <h6>PLAYBOI BABY</h6>
        <div className="info__container">
          <div className="info__flag"
               style={{backgroundImage: `url(${country.countryInfo.flag})`}}/>
          <div className="info__name">
            {country.country}
          </div>
          <div className="info__confirmed">```


            {/*1. console error (Uncaught TypeError: Class constructor Numeral cannot be invoked without 'new'), i had checked the numeral docs and i did everything as stated in it.*/}


            Cases: {numeral(country.cases).format("0,0")}
          </div>
          <div className="info__recovered">
            Recovered: {numeral(country.recovered).format("0,0")}
          </div>
          <div className="info__deaths">
            Deaths: {numeral(country.deaths).format("0,0")}
          </div>
        </div>
      </Popup>
    </Circle>
  ))
);
  1. console error: Uncaught TypeError: Class constructor Numeral cannot be invoked without 'new', I had checked the numeral docs and I did everything as stated in it.
Cases: {numeral(country.cases).format("0,0")}
          </div>
          <div className="info__recovered">
            Recovered: {numeral(country.recovered).format("0,0")}
          </div>
          <div className="info__deaths">
            Deaths: {numeral(country.deaths).format("0,0")}
          </div>
        </div>
      </Popup>
    </Circle>
  ))
);
  1. console error: Uncaught TypeError: Class constructor Numeral cannot be invoked without 'new', not just in this component but in every component where react-numeral appears.
export const prettyPrintStat = (stat) => (
  stat ? `+${numeral(stat).format("0.0a")}` : "+0"
)

export const sortData = (data) => {
  const sortedData = [...data];

  return sortedData.sort((a, b) => (a.cases > b.cases ? -1 : 1))
};

Upvotes: 0

Views: 84

Answers (0)

Related Questions