Q:

get syntethicbaseevent and parameter in react

import React from 'react';

function App() {

  function sayHello() {
    alert('Hello!');
  }
  
  return (
    <button onClick={sayHello}>
      Click me!
    </button>
  );
}

export default App;
2
//Event hadling in react
function ActionLink() {
  function handleClick(e) {
    e.preventDefault();
    console.log('The link was clicked.');
  }

  return (
    <a href="#" onClick={handleClick}>
      Click me
    </a>
  );
}
0
Try this:

<button onClick={(e) => clickMe(e, someParameter)}>Click Me!</button>

And in your function:

function clickMe(event, someParameter){
     //do with event
}
0

New to Communities?

Join the community