Snipps by Patrik

Inline function in an onClick event handler in React

Inline functions allow you to write code for event handling directly in JSX. See the example below:

import React from "react";

const App = () => {
  return (
    <button onClick={() => alert("Hello!")}>Say Hello</button>

export default App;


Leave a Comment

All fields are required. Your email address will not be published.