[Bug Report] 基于 useField 做的 arrayItems,调用 remove 方法删除 item 时未生效
- Dominant language
- TypeScript
- Stars
- 12.6k
- Forks
- 1.6k
- PR merge metrics
- No merged PRs in 30d
Description
- [ ] I have searched the [issues](https://github.com/alibaba/formily/issues) of this repository and believe that this is not a duplicate.
### Reproduction link
[](https://codesandbox.io/p/sandbox/formily-react-antd-markup-schema-fvpevx?file=%2FApp.tsx%3A42%2C11)
### Steps to reproduce
ArrayBase.Remove = React.forwardRef((props, ref) => {
const index = useIndex(props.index)
const self = useField()
const array = useArray()
const prefixCls = usePrefixCls('formily-array-base')
if (!array) return null
if (array.field?.pattern !== 'editable') return null
return (
{
if (self?.disabled) return
e.stopPropagation()
if (props.onClick) {
props.onClick(e)
if (e.defaultPrevented) return
}
console.log('remove inner', index);
array.field?.remove?.(index!)
array.props?.onRemove?.(index!)
}}
>
{isUndef(props.prefix) ? : props.prefix}
{props.title || self.title}
)
})
{
console.log('remove effet', index);
}
}}
>
### What is expected?
点击删除,关联 item 被销毁
### What is actually happening?
点击删除,关联 item 仍然存在
### Package
@formily/react@2.2.23
---
Contributor guide
Research direction
Start with the CodeSandbox reproduction in App.tsx at the linked location and inspect the ArrayItems.Remove entry point shown in the report. Reproduce the click behavior with @formily/react@2.2.23, then trace whether the array field receives the item index. Done means clicking Remove destroys the associated item and the onRemove callback still receives the index.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100