Answers for "how to call a function in react with arguments onclick"

5

react onclick parameter

import React from 'react';

const ExampleComponent = () => {
  
  function sayHello(name) {
    alert(`hello, ${name}`);
  }
  
  return (
    <button onClick={() => sayHello('James')}>Greet</button>
  );
}

export default ExampleComponent;
Posted by: Guest on September-11-2020
3

how to call a function in react with arguments onclick

<button onClick={() => sayHello('James')}>Greet</button>
Posted by: Guest on September-05-2020

Code answers related to "how to call a function in react with arguments onclick"

Code answers related to "Javascript"

Browse Popular Code Answers by Language