Skip to content

Commit

Permalink
Extract isSlotFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
connorlanigan committed Sep 7, 2023
1 parent aff43c8 commit 59cfc2a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/attribute-editor/row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ function render<T>(
itemIndex: number,
slot: AttributeEditorProps.FieldRenderable<T> | React.ReactNode | undefined
) {
if (typeof slot === 'function') {
return (slot as AttributeEditorProps.FieldRenderable<T>)(item, itemIndex);
if (isSlotFunction(slot)) {
return slot(item, itemIndex);
}
return slot;

function isSlotFunction(slot: unknown): slot is AttributeEditorProps.FieldRenderable<T> {
return typeof slot === 'function';
}
}

const GRID_DEFINITION = [{ colspan: { default: 12, xs: 9 } }];
Expand Down

0 comments on commit 59cfc2a

Please sign in to comment.