Guest User

Untitled

a guest
Mar 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. const Elem = (props) =>{
  2. return (<div>
  3. <h1 onClick={props.clickon} id="GM"> Good Morning!
  4. <br/>
  5. {props.name} {props.last}
  6. <br />
  7. This is phase three</h1>
  8. <button id="btn1" onClick={props.clickon}> {props.text} </button>
  9. <button id="btn2" onClick={props.clickon}> Second Button </button>
  10. </div>
  11. );
  12. };
  13.  
  14.  
  15.  
  16. class App extends React.Component{
  17. constructor(props) {
  18. super(props);
  19. this.handleClick = this.handleClick.bind(this);
  20. }
  21.  
  22. handleClick(){
  23. var clickedId = event.target.id;
  24. console.log(clickedId);
  25. alert("It works! You clicked " + clickedId)
  26. }
  27. render(){
  28. return (
  29. <Elem name = 'paul' last='shreeman' clickon={this.handleClick} text='PushMe'/>
  30. )
  31. }
  32. }
  33.  
  34. ReactDOM.render(
  35. <App />, document.getElementById('root'))
  36.  
  37. handleClick(event) {
  38. var clickedId = event.target.id;
  39. console.log(clickedId);
  40. alert("It works! You clicked " + clickedId)
  41. }
  42.  
  43. const Elem = (props) =>{
  44. return (<div>
  45. <h1 onClick={props.clickon} id="GM"> Good Morning!
  46. <br/>
  47. {props.name} {props.last}
  48. <br />
  49. This is phase three</h1>
  50. <button id="btn1" onClick={props.clickon}> {props.text} </button>
  51. <button id="btn2" onClick={props.clickon}> Second Button </button>
  52. </div>
  53. );
  54. };
  55.  
  56.  
  57.  
  58. class App extends React.Component{
  59. constructor(props) {
  60. super(props);
  61. this.handleClick = this.handleClick.bind(this);
  62. }
  63.  
  64. handleClick(event){
  65. var clickedId = event.target.id;
  66. console.log(clickedId);
  67. alert("It works! You clicked " + clickedId)
  68. }
  69. render(){
  70. return (
  71. <Elem name = 'paul' last='shreeman' clickon={(event)=>this.handleClick(event)} text='PushMe'/>
  72. )
  73. }
  74. }
  75.  
  76. ReactDOM.render(
  77. <App />, document.getElementById('root'))
Add Comment
Please, Sign In to add comment