fix(client): avoid cannot getField by randomly generated name and throw error (#294)

Co-authored-by: chenos <chenlinxh@gmail.com>
This commit is contained in:
Junyi 2022-04-17 18:09:46 +08:00 committed by GitHub
parent fcfde7ed0a
commit 8e11e8d364
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,7 +18,7 @@ export const ReadPrettyRecordPicker: React.FC = observer((props: any) => {
const { getField } = useCollection();
const collectionField = getField(fieldSchema.name);
const [record, setRecord] = useState({});
return (
return collectionField ? (
<div>
<BlockAssociationContext.Provider value={`${collectionField.collectionName}.${collectionField.name}`}>
<CollectionProvider name={collectionField.target}>
@ -48,5 +48,5 @@ export const ReadPrettyRecordPicker: React.FC = observer((props: any) => {
</CollectionProvider>
</BlockAssociationContext.Provider>
</div>
);
) : null;
});