Skip to content

Instantly share code, notes, and snippets.

@HyunSeob
Created July 15, 2018 05:09
Show Gist options
  • Save HyunSeob/64e45981398c770db69867f556e64c20 to your computer and use it in GitHub Desktop.
Save HyunSeob/64e45981398c770db69867f556e64c20 to your computer and use it in GitHub Desktop.
import React, { StatelessComponent, ButtonHTMLAttributes } from 'react';
import { render } from 'react-dom';
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
color?: string
}
const Button: StatelessComponent<ButtonProps> = ({ color, children, ...props }) => (
<button style={{ color }} {...props}>{children}</button>
)
render((
<div>
<Button color="red">Button1</Button>
<Button color="red" onClick={() => console.log('Yeahhs')}>Button2</Button> {/* Okay now */}
</div>
), document.getElementById('root'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment