Created
December 3, 2016 03:03
-
-
Save EQuimper/428baa8df2443486c722801ee95581d0 to your computer and use it in GitHub Desktop.
Children in react
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
const checkSize = size => { | |
switch (size) { | |
case 'large': | |
return 100; | |
case 'medium': | |
return 75; | |
default: | |
return 50; | |
} | |
} | |
const Button = ({ children, color, size, onClick }) => { | |
return ( | |
<button | |
style={{ backgroundColor: color, width: checkSize(size) }} | |
onClick={onClick} | |
> | |
{children} | |
</button> | |
) | |
} | |
const Thinkful = () => ( | |
<div> | |
<Button onClick={() => alert('Small')} color="pink"> | |
Small | |
</Button> | |
<br/> | |
<Button size="medium" onClick={() => alert('Medium')} color="yellow"> | |
Medium | |
</Button> | |
<br/> | |
<Button size="large" onClick={() => alert('Large')} color="blue"> | |
Large | |
</Button> | |
</div> | |
); | |
export default Thinkful; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment