Arco Design抽屉关闭后怎么自动销毁组件?
我用 Arco 的 Drawer 组件弹出一个表单,但发现即使关闭了抽屉,里面的组件实例还在内存里,数据也没重置。试过设置 unmountOnClose 为 true,但好像没生效?
这是我的用法:
const [visible, setVisible] = useState(false);
return (
<>
<Button onClick={() => setVisible(true)}>打开</Button>
<Drawer
visible={visible}
unmountOnClose={true}
onClose={() => setVisible(false)}
>
<MyFormComponent />
</Drawer>
</>
);
是不是哪里写错了?为啥关闭后 MyFormComponent 还没被卸载?
unmountOnClose改成destroyOnClose,Arco Drawer 的属性名是destroyOnClose不是unmountOnClose,后者是 Ant Design 的写法,Arco 用的是destroyOnClose。