Skip to content

Commit

Permalink
fix progress
Browse files Browse the repository at this point in the history
  • Loading branch information
erwan committed Nov 26, 2024
1 parent 8943490 commit fa2307b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
35 changes: 17 additions & 18 deletions packages/react/components/progress/Progress.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,24 +95,23 @@ const Progress = React.forwardRef(
return (
<View style={styles.progress} {...others} ref={ref}>
{Array.isArray(children) &&
children.map(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(child: any, index: number) =>
(child &&
child.type.name === 'ProgressItem' &&
React.cloneElement(child, {
key: index,
style: [
index === 0 && styles.progressItemFirst,
index === children.length - 1 && styles.progressItemSecond,
{
backgroundColor: getColorStyle(child.props.status),
height: height,
},
],
})) ||
child,
)}
children.map((child, index: number) => {
if (child && child?.type?.render?.displayName === 'ProgressItem') {
return React.cloneElement(child, {
key: index,
style: [
index === 0 && styles.progressItemFirst,
index === children.length - 1 && styles.progressItemSecond,
{
backgroundColor: getColorStyle(child.props.status),
height: height,
},
],
})
}

return child
})}
</View>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ const ProgressItem = React.forwardRef(
({ children, percent, status, ...others }: ProgressItemProps, ref: React.Ref<ViewType>): JSX.Element => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const givenProps = others as any
const givenstyle = givenProps.style

const { style } = givenProps
const animation = useRef(new Animated.Value(0)).current

useEffect(() => {
Expand All @@ -37,7 +36,7 @@ const ProgressItem = React.forwardRef(
})

return (
<Animated.View ref={ref} style={[{ width }, ...givenstyle]} {...others}>
<Animated.View ref={ref} style={[{ width }, ...style]}>
{children}
</Animated.View>
)
Expand Down

0 comments on commit fa2307b

Please sign in to comment.