fix(Filter-blocks): should remove option when deleting block

This commit is contained in:
Rairn 2023-03-20 18:00:07 +08:00
parent 070c9c21ec
commit 815768c91d

View File

@ -78,7 +78,7 @@ export const FilterBlockRecord = ({
useEffect(() => { useEffect(() => {
return () => { return () => {
removeDataBlock(field.props.name as string); removeDataBlock(fieldSchema['x-uid']);
}; };
}, []); }, []);
@ -113,8 +113,8 @@ export const useFilterBlock = () => {
setDataBlocks((prev) => [...prev, block]); setDataBlocks((prev) => [...prev, block]);
}; };
const getDataBlocks = () => dataBlocks; const getDataBlocks = () => dataBlocks;
const removeDataBlock = (name: string) => { const removeDataBlock = (uid: string) => {
setDataBlocks((prev) => prev.filter((item) => item.uid !== name)); setDataBlocks((prev) => prev.filter((item) => item.uid !== uid));
}; };
return { recordDataBlocks, getDataBlocks, removeDataBlock }; return { recordDataBlocks, getDataBlocks, removeDataBlock };