Skip to content

Commit

Permalink
fix: don't crash when selecting component with no config
Browse files Browse the repository at this point in the history
Closes #671
  • Loading branch information
chrisvxd authored Nov 6, 2024
1 parent 6adab65 commit cb90f5d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/core/components/Puck/components/Fields/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,18 @@ const useResolvedFields = (): [FieldsType, boolean] => {
? config.components[selectedItem.type]
: null;

const defaultFields = selectedItem
? (componentConfig?.fields as Record<string, Field<any>>)
: rootFields;
const defaultFields =
(selectedItem
? (componentConfig?.fields as Record<string, Field<any>>)
: rootFields) || {};

// DEPRECATED
const rootProps = data.root.props || data.root;

const [lastSelectedData, setLastSelectedData] = useState<
Partial<ComponentOrRootData>
>({});
const [resolvedFields, setResolvedFields] = useState(defaultFields || {});
const [resolvedFields, setResolvedFields] = useState(defaultFields);
const [fieldsLoading, setFieldsLoading] = useState(false);

const defaultResolveFields = (
Expand Down

0 comments on commit cb90f5d

Please sign in to comment.