onclick an event to get that state value react code example Example: react button onclick <button onClick={sayHello}>Click</button>