From e1fc8ea5904de90f94d3f63287555c75067846ac Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sun, 14 Mar 2021 03:03:12 +0300 Subject: feat: add Page component --- src/components/Button.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/components/Button.tsx') diff --git a/src/components/Button.tsx b/src/components/Button.tsx index 8f2398b..5724b40 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -1,6 +1,9 @@ -import React from 'react'; +import React, { useCallback } from 'react'; +import { useHistory } from 'react-router-dom'; interface Props { + onClick?: () => void; + route?: string; variant?: 'contained' | 'outlined'; size?: 'sm' | 'md' | 'lg'; children: string; @@ -18,10 +21,14 @@ const sizes = { sm: 'p-3', }; -const Button: React.FC = ({ variant = 'contained', size = 'md', children }) => { +const Button: React.FC = ({ onClick, route, variant = 'contained', size = 'md', children }) => { + const history = useHistory(); + const navigateRoute = useCallback(() => history.push(route || '/'), [route, history]); + return (