Button exercise: adding props

main
Gerardo Marx 2 weeks ago
parent 339e914e82
commit b120028817

@ -1,11 +1,16 @@
import { Button } from "./components/Button"; import { Button } from "./components/Button";
function handleOnClick() {
console.log("Clicked");
}
function App() { function App() {
return ( return (
<div> <div>
<Button/> <Button onClick={handleOnClick} color="secondary">My Button</Button>
</div> </div>
); );
} }

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

Loading…
Cancel
Save