@momo-kits/rating 0.167.2-beta.1 → 0.168.1-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.tsx +9 -4
  2. package/package.json +1 -1
package/index.tsx CHANGED
@@ -3,6 +3,13 @@ import React, {FC} from 'react';
3
3
  import {StyleSheet, TouchableOpacity, View} from 'react-native';
4
4
  import {RatingProps} from './type';
5
5
 
6
+ const toNumber = (value: number | string) => {
7
+ if (typeof value === 'string') {
8
+ return parseFloat(value.replace(',', '.'));
9
+ }
10
+ return value;
11
+ };
12
+
6
13
  const Rating: FC<RatingProps> = ({
7
14
  rating,
8
15
  numOfStars,
@@ -11,10 +18,8 @@ const Rating: FC<RatingProps> = ({
11
18
  style,
12
19
  ...props
13
20
  }) => {
14
- const normalizedRating =
15
- typeof rating === 'string' ? parseFloat(rating.replace(',', '.')) : rating;
16
- const normalizedNumOfStars =
17
- typeof numOfStars === 'string' ? parseFloat(numOfStars) : numOfStars;
21
+ const normalizedRating = toNumber(rating);
22
+ const normalizedNumOfStars = toNumber(numOfStars);
18
23
 
19
24
  const renderStar = (index: number) => {
20
25
  // Full star
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/rating",
3
- "version": "0.167.2-beta.1",
3
+ "version": "0.168.1-beta.10",
4
4
  "private": false,
5
5
  "main": "index.tsx",
6
6
  "peerDependencies": {