ekeric13 / react-star-ratings

A customizable svg star rating component for selecting x stars or visualizing x stars
https://codepen.io/ekeric13/project/full/DkJYpA/
BSD 3-Clause "New" or "Revised" License
152 stars 44 forks source link

TypeError: currentRating.toFixed is not a function #37

Closed lieferbaer closed 4 years ago

lieferbaer commented 4 years ago

link: https://qwrqwr.de/productListing/delivery/76133/Kaiserallee%201,%2076133%20Karlsruhe/2

click to rated star in the middle.

get node_modules/react-star-ratings/build/star-ratings.js:136

133 | var hoveredRating = this.state.highestStarHovered; 134 | var currentRating = hoveredRating > 0 ? hoveredRating : selectedRating; 135 | // fix it at 2 decimal places and remove trailing 0s

136 | var formattedRating = parseFloat(currentRating.toFixed(2)).toString();
| ^ 137 | if (Number.isInteger(currentRating)) {
138 | formattedRating = String(currentRating);
139 | }
PixelPraful commented 4 years ago

The rating you are passing as a prop must be integer. Use parseFloat(your_rating) as rating prop.