Quotes help make search much faster. Example: "Practice Makes Perfect"

Tuesday, August 14, 2018

Codecademy Sample Solution: Use an Event Listener in a Component


// sample solution to app.js

import React from 'react';
import ReactDOM from 'react-dom';

class Button extends React.Component {
  scream() {
    alert('AAAAAAAAHHH!!!!!');
  }

  render() {
    return <button onClick={this.scream}>AAAAAH!</button>;
  }
}

ReactDOM.render(
<Button />,
  document.getElementById('app')
);

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts