Created
July 7, 2016 09:47
-
-
Save kazagkazag/01bc99926536bc7f83f764fdc7c8d4dc to your computer and use it in GitHub Desktop.
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
// MyButton.jsx | |
function MyButton(props) { | |
return <button onClick={props.onButtonClick}>{props.buttonTitle}</button>; | |
} | |
export default MyButton; | |
// MyComponent.jsx | |
export class MyComponent extends Component { | |
constructor(props) { | |
super(props); | |
this.onButtonClick = this.onButtonClick.bind(this); | |
} | |
render() { | |
return ( | |
<div className="my-div"> | |
My div content | |
<MyButton onButtonClick={this.onButtonClick} buttonTitle="Click me!" /> | |
</div> | |
); | |
} | |
onButtonClick() { | |
console.log("Click!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment