Skip to content

Instantly share code, notes, and snippets.

@HyunSeob
Created July 15, 2018 05:51
Show Gist options
  • Save HyunSeob/bb25fc446d36dcea964f8bf7d64641b3 to your computer and use it in GitHub Desktop.
Save HyunSeob/bb25fc446d36dcea964f8bf7d64641b3 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import { render } from 'react-dom';
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {}
class Button extends Component<ButtonProps> {
handleClick = () => {
this.props.onClick(this.props.value) // Error!
}
render() {
return <button {...this.props} onClick={this.handleClick} />
}
}
render((
<Button
value="Hello"
onClick={() => console.log(value + ', world!')}
>
Button
</Button>
), document.getElementById('root'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment