Skip to content

Commit 863fab6

Browse files
author
Rishabh
committed
updating code to accomodate number of stars to show when user passes totalCount
1 parent 225fdaa commit 863fab6

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

package.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,7 @@
3333
"react-native": "^0.57.1"
3434
},
3535
"devDependencies": {
36-
"babel-eslint": "^8.0.0",
37-
"eslint": "^4.5.0",
38-
"eslint-plugin-react": "^7.0.0",
39-
"metro-react-native-babel-preset": "^0.59.0",
40-
"react": "^16.13.1",
41-
"react-native": "^0.57.1"
36+
"metro-react-native-babel-preset": "^0.59.0"
4237
},
4338
"dependencies": {
4439
"prop-types": "^15.7.2",

src/Rating/index.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,13 @@ const Rating = ({
3838
return (
3939
<StyledView>
4040
<BackgroundStars>
41-
<StarIcon name={icon} size={size} color={ratingBackgroundColor} />
42-
<StarIcon name={icon} size={size} color={ratingBackgroundColor} />
43-
<StarIcon name={icon} size={size} color={ratingBackgroundColor} />
44-
<StarIcon name={icon} size={size} color={ratingBackgroundColor} />
45-
<StarIcon name={icon} size={size} color={ratingBackgroundColor} />
41+
{Array.from({ length: totalCount }, (_, i) => (
42+
<StarIcon name={icon} size={size} color={ratingBackgroundColor} />
43+
))}
4644
<ColoredStars percentage={percentage}>
47-
<StarIcon name={icon} size={size} color={ratingColor} />
48-
<StarIcon name={icon} size={size} color={ratingColor} />
49-
<StarIcon name={icon} size={size} color={ratingColor} />
50-
<StarIcon name={icon} size={size} color={ratingColor} />
51-
<StarIcon name={icon} size={size} color={ratingColor} />
45+
{Array.from({ length: totalCount }, (_, i) => (
46+
<StarIcon name={icon} size={size} color={ratingColor} />
47+
))}
5248
</ColoredStars>
5349
</BackgroundStars>
5450
</StyledView>

0 commit comments

Comments
 (0)