Skip to content

Commit

Permalink
fix(antd): fix array tabs waring (#3629)
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang authored Dec 16, 2022
1 parent 200af68 commit a7e8089
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions packages/antd/src/array-tabs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,28 @@ interface IFeedbackBadgeProps {
index: number
}

const FeedbackBadge: ReactFC<IFeedbackBadgeProps> = observer((props) => {
const field = useField<ArrayField>()
const tab = `${field.title || 'Untitled'} ${props.index + 1}`
const errors = field.errors.filter((error) =>
error.address.includes(`${field.address}.${props.index}`)
)
if (errors.length) {
return (
<Badge size="small" className="errors-badge" count={errors.length}>
{tab}
</Badge>
const FeedbackBadge: ReactFC<IFeedbackBadgeProps> = observer(
(props) => {
const field = useField<ArrayField>()
const tab = `${field.title || 'Untitled'} ${props.index + 1}`
const errors = field.errors.filter((error) =>
error.address.includes(`${field.address}.${props.index}`)
)
if (errors.length) {
return (
<Badge size="small" className="errors-badge" count={errors.length}>
{tab}
</Badge>
)
}
return <Fragment>{tab}</Fragment>
},
{
scheduler(request) {
requestAnimationFrame(request)
},
}
return <Fragment>{tab}</Fragment>
})
)

export const ArrayTabs: React.FC<React.PropsWithChildren<TabsProps>> = observer(
(props) => {
Expand All @@ -54,7 +61,6 @@ export const ArrayTabs: React.FC<React.PropsWithChildren<TabsProps>> = observer(
field.remove(index)
}
}

return (
<Tabs
{...props}
Expand Down Expand Up @@ -83,6 +89,11 @@ export const ArrayTabs: React.FC<React.PropsWithChildren<TabsProps>> = observer(
})}
</Tabs>
)
},
{
scheduler(request) {
requestAnimationFrame(request)
},
}
)

Expand Down

0 comments on commit a7e8089

Please sign in to comment.