📱🚀 🧩 Cross Device & High Performance Normal Form/Dynamic(JSON Schema) Form/Form Builder -- Support React/React Native/Vue 2/Vue 3
11.32k
stars
1.48k
forks
source link
[Bug Report] 基于 useField 做的 arrayItems,调用 remove 方法删除 item 时未生效 #4036
Open
liuguibin0828 opened 10 months ago
Reproduction link
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 ( <Button ref={ref} type="text" {...props} disabled={self?.disabled} className={cls(
${prefixCls}-remove
, self?.disabled ?${prefixCls}-remove-disabled
: '', props.className )} onClick={(e) => { 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!) }}<SchemaField.Array name="string_array" title="字符串数组" x-decorator="FormItem" x-component="ArrayItems" x-component-props={{ onRemove: (index) => { console.log('remove effet', index); } }}
What is expected?
点击删除,关联 item 被销毁
What is actually happening?
点击删除,关联 item 仍然存在
Package
@formily/react@2.2.23