为什么destroyOnClose = {true}在React中不起作用

问题描述

我正在使用TypeScript开发基于React钩子的功能应用程序,并且正在使用蚂蚁设计中的模式。我正在通过模式提交表格表格。因此,将多次调用该模式以填充表的不同行。

问题是,当模态第二次,第三次或横向弹出时,它总是带有先前的值。

为避免这种情况,我在模式EnableViewState="false"中进行了设置,但此方法无效。我设置 destroyOnClose={true}。没用在modal documentation中,它是在当destroyOnClose不起作用时编写的,我们需要使用。但是在哪里定义呢?因为当我设置为 <Form onSubmit={props.inputSubmit} preserve={false}以我的模式形式出现,我收到一条错误消息,说Type '{ children: Element[]; onSubmit: any; preserve: boolean; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Form>......?

您使用什么以便每次模态重新加载时都将其重新加载为空?我不想在输入的表单值字段中分配状态。还有其他选择,例如destroyOnClose = {true}吗?

这是我的模态,

<Form onSubmit={props.inputSubmit}>
  <Row>
    <Col span={10}>
      <Form.Item>
        <Text strong={true}>Article name: </Text>
      </Form.Item>
    </Col>
    <Col span={12}>
      <Form.Item>
        <Input
          style={{ backgroundColor: '#e6f9ff' }}
          name="articleName"
          onChange={props.handleArticleModalInput}
        />
      </Form.Item>
    </Col>
  </Row>
</Form>

这里是调用模态的地方,

return (
  <>
    <ArticleTableModal
      destroyOnClose={true}
      isVisible={modalVisibilty}
      inputSubmit={inputSubmit}
      handleCancel={handleCancel}
      filledData={fetchedData}
      articleNumber={articleNumber}
      handleArticleModalInput={handleArticleModalInput}

    />

    <Table
      pagination={false}
      dataSource={articleDataSource}
      columns={articleColumns}
      scroll={{ y: 400 }}
      bordered
    />
  </>
)

非常感谢您的帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)