title: passing a parameter from input text through onClick on reactjs
body: <p>im trying to pass a string to a function using <code>onClick</code> method, here is my code :</p>
  
  <p>App.js </p>
  
  <pre><code>import React from 'react';
  import logo from './logo.svg';
  import './App.css';
  
  const todos = [
  {id: 1, nama: 'belajar', status: 'selesai'},
  {id: 2, nama: 'makan', status: 'belum selesai'}
  ]
  
  export class MyTodos extends React.Component{
    constructor(){
      super();
      this.sayHello = this.sayHello.bind(this);
    }
  }
  
  function sayHello(name) {
    alert(`hello, ${this.name}`);
  }
  
  function App() {
    return (
      &lt;div className="App"&gt;
        &lt;div className="Navbar"&gt;
          &lt;nav className="navbar navbar-dark bg-dark rounded-pill col-sm-8"&gt;  
            &lt;input type="text" className="form-control form-control-sm col-sm-6 rounded-pill" name="aktivitas"&gt;&lt;/input&gt;
            &lt;button className="btn form-control form-control-sm col-sm-4 bg-light rounded-pill" onClick={() =&gt; sayHello(this.aktivitas)}&gt;
              Tambah
            &lt;/button&gt;
          &lt;/nav&gt;
        &lt;/div&gt;
        &lt;br&gt;&lt;/br&gt;&lt;br&gt;&lt;/br&gt;
        &lt;div className="Kartu card"&gt;
          &lt;ul className="list-group list-group-flush"&gt; 
                {todos.map(todos =&gt; &lt;li className="list-group-item"&gt;{todos.nama} : {todos.status}&lt;/li&gt;)}
          &lt;/ul&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    );
  }
  
  
  
  
  export default App;
  </code></pre>
  
  <p>the expected output is, when i type something inside the <code>input field</code> it will give me an alert that says <code>Hello, &lt;inputted string&gt;</code> For example if i type <code>name</code> inside the <code>input field</code> it will gave me <code>hello, name</code></p>
  
  <p>i guess it have something to do with binding something, i tried to bind it bit it gave me this error :
  <code>TypeError: Cannot read property 'aktivitas' of undefined</code></p>
  
  <p>thanks before, any help will be appreciated</p>