Skip to content

Instantly share code, notes, and snippets.

@phongvh
Created June 5, 2018 00:43
Show Gist options
  • Save phongvh/e049ba12457defdd1ce3b44c4d6f4a6c to your computer and use it in GitHub Desktop.
Save phongvh/e049ba12457defdd1ce3b44c4d6f4a6c to your computer and use it in GitHub Desktop.
/************
OLD WAY
************/
<button className="btn btn-lg btn-success add-to-cart">
<img src="/public/images/ic-check.svg" alt="" /> Vote
</button>
/************
NEW WAY: Button.js
************/
export default (props) =>
<button className="btn {props.className}" style={props.style}>
<img src="{props.icon}" alt="" /> {this.children}
</button>
/************
USAGE
************/
import Button from './Button.js'
const App = () => <Button className="btn-lg btn-success add-to-cart" icon="/public/images/ic-check.svg">Vote</Button>
/************
UNIT TEST
************/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment