0
I am attending the basic course of Reactjs of João Ribeiro, and in class 17 he writes the following code:
class App extends React.Component {
metodo = (texto) => {
console.log(texto)
}
render() {
return (
<div>
<button onClick={this.metodo('Olá mundo')}>Clicar</button>
</div>
)
}
}
ReactDOM.render(<App /> , document.getElementById('root'))
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
<div id="root"></div>
My question is: Why the "Hello world" already appears on the console even before the click receive button?