Skip to content

Commit 3e2b603

Browse files
author
Rishabh
committed
fixing common errors
1 parent 0d89653 commit 3e2b603

File tree

2 files changed

+23
-38
lines changed

2 files changed

+23
-38
lines changed

src/Rating/components/IconBar.js

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -25,40 +25,25 @@ const IconBar = ({
2525
selectedIconImage,
2626
emptyIconImage,
2727
filled = false,
28-
}) => {
29-
const emptyIcon = type === "custom" ? emptyIconImage : name;
30-
const filledIcon = type === "custom" ? selectedIconImage : name;
31-
32-
return (
33-
<TouchableOpacity
34-
onPress={() => {
35-
if (!readonly) {
36-
onIconTap(position + 1);
37-
}
38-
}}
39-
>
40-
{type === "custom" ? (
41-
<StyledImage
42-
source={filled ? filledIcon : emptyIcon}
43-
margin={margin}
44-
size={size}
45-
/>
46-
) : (
47-
<StyledIcon
48-
onPress={() => {
49-
if (!readonly) {
50-
onIconTap(position + 1);
51-
}
52-
}}
53-
name={name}
54-
size={size}
55-
color={color}
56-
margin={margin}
57-
/>
58-
)}
59-
</TouchableOpacity>
60-
);
61-
};
28+
}) => (
29+
<TouchableOpacity
30+
onPress={() => {
31+
if (!readonly) {
32+
onIconTap(position + 1);
33+
}
34+
}}
35+
>
36+
{type === "custom" ? (
37+
<StyledImage
38+
source={filled ? selectedIconImage : emptyIconImage}
39+
margin={margin}
40+
size={size}
41+
/>
42+
) : (
43+
<StyledIcon name={name} size={size} color={color} margin={margin} />
44+
)}
45+
</TouchableOpacity>
46+
);
6247

6348
IconBar.propTypes = {
6449
color: PropTypes.string,

src/Rating/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ const Rating = ({
5151
{Array.from({ length: totalCount }, (_, i) => (
5252
<IconBar
5353
name={icon}
54+
key={`bgstar_${i}`}
5455
size={size}
5556
position={i}
56-
key={`bgstar_${i}`}
5757
color={ratingBackgroundColor}
5858
margin={marginBetweenRatingIcon}
5959
onIconTap={onIconTap}
@@ -66,18 +66,18 @@ const Rating = ({
6666
<ColoredIcons percentage={percentage} dir={direction}>
6767
{Array.from({ length: totalCount }, (_, i) => (
6868
<IconBar
69+
filled
6970
name={icon}
71+
key={`cstar_${i}`}
7072
size={size}
71-
color={ratingColor}
7273
position={i}
73-
key={`cstar_${i}`}
74+
color={ratingColor}
7475
margin={marginBetweenRatingIcon}
7576
onIconTap={onIconTap}
7677
readonly={readonly}
7778
type={type}
7879
selectedIconImage={selectedIconImage}
7980
emptyIconImage={emptyIconImage}
80-
filled
8181
/>
8282
))}
8383
</ColoredIcons>

0 commit comments

Comments
 (0)