0
<Button variant={inf.variant} onClick={`${inf.click}`}>

Like this im asking in this onclick

if.click is a string which is = "()=>handleEdit(data)"

2
  • 1
    onClick in React is not like onclick in HTML, it accepts an actual function, not a string. For example onClick={handleClick} or onClick={() => alert("click")} Commented Sep 28, 2022 at 13:02
  • if you want pass the function to Button component then pass it as a prop like: <Button propName={functionName} /> Commented Sep 28, 2022 at 13:27

1 Answer 1

1

The value of onClick should be a function. Not a string.

For example:

<button onClick={functionName}> btn </button>

or

<button onClick={() => { /* code of the function */ }> btn </button>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.