Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

how to change button style by props? [closed]

$
0
0

I want to pass a theme as a parameter to my component button but the style is not being applied

My Component:

interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {  theme: string}const Button: React.FC<ButtonProps> = ({ children, theme }) => {  return (<Container type="button" theme={theme}>      {children}</Container>  )}

Styles file:

const theme = {  blue: {    default: '#3f51b5',    hover: '#283593'  },  pink: {    default: '#e91e63',    hover: '#ad1457'  }}export const Container = styled.button`  display: flex;  justify-content: center;  background: ${props => theme[props.theme].defautl};

My index:

<Button theme="pink">Click</Button>

does anyone know where the error is or how can i do this?


Viewing all articles
Browse latest Browse all 6287

Trending Articles