Skip to content

Commit

Permalink
Merge pull request mallfoundry#676 from hbztd/fix/timeline
Browse files Browse the repository at this point in the history
fix(flex): text child render fail
  • Loading branch information
Pilotager authored Feb 4, 2024
2 parents b049aa6 + 5f86f91 commit fd34065
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/core/src/flex/flex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
cloneElement,
CSSProperties,
forwardRef,
ReactElement,
isValidElement,
ReactNode,
useMemo,
} from "react"
Expand Down Expand Up @@ -78,12 +78,14 @@ const Flex = forwardRef((props: FlexProps, ref) => {

const children = useMemo(
() =>
Children.map(childrenProp, (item, index) =>
cloneElement(item as ReactElement, {
__dataIndex__: index,
__dataLength__: Children.count(childrenProp),
}),
),
Children.map(childrenProp, (item, index) => {
return isValidElement<any>(item)
? cloneElement(item, {
__dataIndex__: index,
__dataLength__: Children.count(childrenProp),
})
: item
}),
[childrenProp],
)

Expand Down

0 comments on commit fd34065

Please sign in to comment.