From 964ecdf848817393e42016f70465dd23374a9eea Mon Sep 17 00:00:00 2001 From: phoenixpereira Date: Wed, 27 Dec 2023 21:09:04 +1030 Subject: [PATCH] refactor: Conditionally render component based on href prop in Button --- src/components/Button.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/Button.tsx b/src/components/Button.tsx index 32f5334c..3225a46f 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -5,18 +5,21 @@ import React from 'react'; interface ButtonProps { children: React.ReactNode; colour: string; - href: string; + href?: string; } const Button = ({ children, colour, href }: ButtonProps) => { + const isAnchor = !!href; + const Component = isAnchor ? 'a' : 'button'; + return ( - {children} - + ); };