mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 09:09:03 +00:00
fix: performance optimizations
This commit is contained in:
parent
c4816c6963
commit
c89d7f980f
@ -28,18 +28,20 @@ export const AssociationFieldProvider = observer(
|
||||
[fieldSchema['x-component-props']?.mode],
|
||||
);
|
||||
|
||||
const targetKeyValue = useMemo(() => {
|
||||
if (!field.value) return '';
|
||||
if (['belongsTo', 'hasOne'].includes(collectionField.type)) {
|
||||
return field.value[collectionField.targetKey] ?? '';
|
||||
}
|
||||
if (['belongsToMany', 'hasMany'].includes(collectionField.type)) {
|
||||
if (Array.isArray(field.value)) {
|
||||
return field.value.map((v) => v[collectionField.targetKey] ?? '').join(',');
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}, [collectionField, field.value]);
|
||||
// const targetKeyValue = useMemo(() => {
|
||||
// if (!field.value) return '';
|
||||
// if (['belongsTo', 'hasOne'].includes(collectionField.type)) {
|
||||
// return field.value[collectionField.targetKey] ?? '';
|
||||
// }
|
||||
// if (['belongsToMany', 'hasMany'].includes(collectionField.type)) {
|
||||
// if (Array.isArray(field.value)) {
|
||||
// return field.value.map((v) => v[collectionField.targetKey] ?? '').join(',');
|
||||
// }
|
||||
// }
|
||||
// return '';
|
||||
// }, [collectionField, field.value]);
|
||||
|
||||
const fieldValue = useMemo(() => JSON.stringify(field.value), [field.value]);
|
||||
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
@ -84,7 +86,7 @@ export const AssociationFieldProvider = observer(
|
||||
}
|
||||
setLoading(false);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [currentMode, collectionField, targetKeyValue]);
|
||||
}, [currentMode, collectionField, fieldValue]);
|
||||
|
||||
if (loading) {
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user