Answers for "react onclick parameter"

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
0

pass parameter to handleclick react

import React from 'react';

const ExampleComponent = () => {
  
  function sayHello(name) {
    alert(`hello, ${name}`);
  }
  
  return (
    <button onClick={() => sayHello('James')}>Greet</button>
  );
Posted by: Guest on September-19-2021

Code answers related to "react onclick parameter"

Code answers related to "Javascript"

Browse Popular Code Answers by Language