Button exercise: typescript errors

main
Gerardo Marx 2 weeks ago
parent b120028817
commit fc1a845427

@ -10,7 +10,7 @@ function App() {
return ( return (
<div> <div>
<Button onClick={handleOnClick} color="secondary">My Button</Button> <Button onClick={handleOnClick} color="success">My Button</Button>
</div> </div>
); );
} }

@ -1,11 +1,11 @@
interface Props { interface Props {
children: string; children: string;
color: string; color?: 'primary' | 'secondary' | 'success';
onClick: () => void; onClick: () => void;
} }
export const Button = ({ children, color, onClick }: Props) => { export const Button = ({ children, color='primary', onClick }: Props) => {
//const buttonType = "btn " + "btn"+"-"+{type}; //const buttonType = "btn " + "btn"+"-"+{type};
return ( return (
<button type="button" className={'btn btn-'+color} onClick={onClick}>{children}</button> <button type="button" className={'btn btn-'+color} onClick={onClick}>{children}</button>

Loading…
Cancel
Save