Skip to content

Commit 929fa49

Browse files
committed
refactor(Tile): polymorphic component typing proof of concept
i am kind of muddling through this attempt at making <Tile> work as a polymorphic component because in some cases it renders out an <a> instead of a <div>. right now it doesn't really cover the condition where if `as="a"` is passed as a prop, then the html attributes of <a> are allowed
1 parent 9586777 commit 929fa49

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/ui/components/tiles/Tile.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ const Element = styled.div<ElementProps>`
3232
: ``};
3333
`;
3434

35-
interface TileProps {
35+
interface TileProps<C extends React.ElementType> {
36+
as?: C
3637
space: SpaceValue;
3738
}
3839

39-
const Tile: React.FC<TileProps> = ({ space, ...props }) => (
40+
const Tile = <C extends React.ElementType = "div">({ space, ...props }: TileProps<C>) => (
4041
<SharedHexConsumer>
4142
{({ BIFHEX }) => (
4243
<ThemeProvider

0 commit comments

Comments
 (0)