import React from 'react';
import ReactDOM from 'react-dom/client';
class Football extends React.Component {
constructor(props) {
super(props)
this.shoot = this.shoot.bind(this)
}
shoot() {
alert(this);
/*
Thanks to the binding in the constructor function,
the 'this' keyword now refers to the component object
*/
}
render() {
return (
<button onClick={this.shoot}>Take the shot!</button>
);
}
}
const container = document.getElementById('root');
const root = ReactDOM.createRoot(container);
root.render(<Football />);