-
我的编辑和新增公用的一个页面组件,点进编辑页时通过form.setValues填充数据(内含不是表单项的数据,如id,create_time等字段),返回上一页后进新增页时表单数据还在,如何彻底清空或者卸载表单组件。 useEffect(() => {
return () => {
formStep.setCurrent(0);
form.reset()
};
}, []);
useEffect(() => {
if (params.id) {
setLoading(true);
getSampleByIdAPI(params.id).then((res) => {
form.setValues(res);
setLoading(false);
});
}
}, [params]); |
Beta Was this translation helpful? Give feedback.
Answered by
liudichen
Oct 16, 2023
Replies: 2 comments 1 reply
-
const form = useMemo(()=>createForm({initialValues}),[initialValues]),编辑或新增时重新生成form实例可能就可以了吧,不共用form实例 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
lppoi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
const form = useMemo(()=>createForm({initialValues}),[initialValues]),编辑或新增时重新生成form实例可能就可以了吧,不共用form实例