We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
正常展示
报错白屏
@formily/react@2.2.20
The text was updated successfully, but these errors were encountered:
import React from "react"; import { createForm, ArrayField as ArrayFieldType } from "@formily/core"; import { FormProvider, Field, ArrayField, useField, observer, ObjectField, } from "@formily/react"; import { Input, Button, Space } from "antd"; import { nanoid } from "nanoid"; const form = createForm(); const BaseRule = (props: any) => { const { onRemove } = props; const field = useField(); return ( <> <span style={{ color: "red" }}>规则</span> {/* <Field name="deps" component={[() => "deps"]} /> */} <Button onClick={() => onRemove(field.index)}>删除</Button> </> ); }; const ArrayComponent = observer(() => { const field = useField<ArrayFieldType>(); return ( <div> {field.value?.map((item, index) => ( <div key={item.id}> {item.logic ? ( <ObjectField name={index} component={[ () => ( <div style={{ display: "flex", marginBottom: 16 }}> <span style={{ color: "green", marginRight: "12px" }}> 规则组 </span> {/* <Field name="logic" component={[() => "logic"]} /> */} <ArrayField name="strategy" component={[ArrayComponent]} /> </div> ), ]} reactions={[ (selfField) => { const empty = !selfField.value?.strategy?.length; // selfField.setDisplay(empty ? 'none' : 'visible'); empty && field.remove(selfField.index as any); }, ]} /> ) : ( <div style={{ display: "flex", gap: "12px" }}> <ObjectField name={index} component={[ BaseRule, { onRemove: field.remove, }, ]} /> </div> )} </div> ))} <div style={{ display: "flex", gap: "12px" }}> <Button onClick={() => field.push({ id: nanoid(), }) } > 添加规则 </Button> <Button onClick={() => field.push({ logic: "and", strategy: [ { id: nanoid(), }, ], }) } > 添加规则组 </Button> </div> </div> ); }); export default () => ( <FormProvider form={form}> <ArrayField name="array" component={[ArrayComponent]} /> </FormProvider> );
附上代码
Sorry, something went wrong.
No branches or pull requests
Reproduction link
Steps to reproduce
2.点击添加规则组
4.添加规则
What is expected?
正常展示
What is actually happening?
报错白屏
Package
@formily/react@2.2.20
The text was updated successfully, but these errors were encountered: