Skip to content

Instantly share code, notes, and snippets.

@EQuimper
Created December 3, 2016 03:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EQuimper/428baa8df2443486c722801ee95581d0 to your computer and use it in GitHub Desktop.
Save EQuimper/428baa8df2443486c722801ee95581d0 to your computer and use it in GitHub Desktop.
Children in react
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