0
Q:

react onclick to make another button

import React, { Component } from 'react';

class App extends Component {
  
  constructor(props) {
    super(props);
    this.sayHello = this.sayHello.bind(this);
  }

  sayHello() {
    alert('Hello!');
  }
  
  return (
    <button onClick={this.sayHello}>
      Click me!
    </button>
  );
}

export default App;
8
import React from 'react';

const App = () => {
  
const message = () => {
 console.log("Hello World!") 
}

return (
<button onClick={message}> Press me to print a message! </button>
  );
}
1
<button onClick={sayHello}>Click</button>
3

New to Communities?

Join the community