diff --git a/package.json b/package.json
index 5952fad..cdf1869 100644
--- a/package.json
+++ b/package.json
@@ -35,9 +35,6 @@
"url": "https://github.com/Monte9/react-native-ratings/issues"
},
"homepage": "https://github.com/Monte9/react-native-ratings#readme",
- "dependencies": {
- "lodash": "^4.17.15"
- },
"devDependencies": {
"@types/node": "^14.14.37",
"@types/react": "^17.0.3",
diff --git a/src/SwipeRating.tsx b/src/SwipeRating.tsx
index b40d540..70ff6cd 100644
--- a/src/SwipeRating.tsx
+++ b/src/SwipeRating.tsx
@@ -1,5 +1,4 @@
import React, { Component } from "react";
-import times from "lodash/times";
import {
View,
@@ -209,12 +208,8 @@ export default class SwipeRating extends Component<
constructor( props ) {
super( props );
- const {
- onStartRating,
- onSwipeRating,
- onFinishRating,
- fractions
- } = this.props;
+ const { onStartRating, onSwipeRating, onFinishRating, fractions } =
+ this.props;
const position = new Animated.ValueXY();
const panResponder = PanResponder.create( {
@@ -366,15 +361,20 @@ export default class SwipeRating extends Component<
renderRatings() {
const { imageSize, ratingCount, type, tintColor } = this.props;
const { source } = TYPES[type];
+ const rating_array = [];
+
+ for ( let i = 0; i < ratingCount; i += 1 ) {
+ rating_array.push(
+
+
+
+ );
+ }
- return times( ratingCount, index =>
-
-
-
- );
+ return rating_array;
}
// eslint-disable-next-line max-statements
@@ -443,13 +443,8 @@ export default class SwipeRating extends Component<
}
displayCurrentRating() {
- const {
- ratingCount,
- type,
- readonly,
- showReadOnlyText,
- ratingTextColor
- } = this.props;
+ const { ratingCount, type, readonly, showReadOnlyText, ratingTextColor } =
+ this.props;
const color = ratingTextColor || TYPES[type].color;
return (
@@ -573,5 +568,6 @@ const styles = StyleSheet.create( {
textAlign: "center",
fontFamily: Platform.OS === "ios" ? "Trebuchet MS" : null,
color: "#34495e"
- }
+ },
+ starContainer: {}
} );
diff --git a/src/TapRating.tsx b/src/TapRating.tsx
index a1a23f2..e27c037 100644
--- a/src/TapRating.tsx
+++ b/src/TapRating.tsx
@@ -1,5 +1,3 @@
-import _ from "lodash";
-
import React, { useState, useEffect } from "react";
import { StyleSheet, Text, View, StyleProp, ViewStyle } from "react-native";
@@ -64,7 +62,7 @@ export type TapRatingProps = {
*
* Default is none
*/
- ratingContainerStyle?: StyleProp;
+ ratingContainerStyle?: StyleProp;
/**
* Callback method when the user finishes rating. Gives you the final rating value as a whole number
@@ -111,12 +109,6 @@ const TapRating: React.FunctionComponent = props => {
}
}, [props.defaultRating] );
- const renderStars = rating_array => {
- return _.map( rating_array, star => {
- return star;
- } );
- };
-
const starSelectedInPosition = position => {
const { onFinishRating } = props;
@@ -141,19 +133,19 @@ const TapRating: React.FunctionComponent = props => {
ratingContainerStyle.push( props.ratingContainerStyle );
}
- _.times( count, index => {
+ for ( let i = 0; i < count; i += 1 ) {
rating_array.push(
{
starSelectedInPosition( value );
}}
- fill={position >= index + 1}
+ fill={position >= i + 1}
{...props}
/>
);
- } );
+ }
return (
@@ -167,7 +159,7 @@ const TapRating: React.FunctionComponent = props => {
{reviews[position - 1]}
}
- {renderStars( rating_array )}
+ {rating_array}
);
};