'undefiend parameter in function while passing it through props react js

i am passing a function called updatenote from parent file to child file through props but when i am calling it , i am getting a error in child class currentnote parameter of updateNote is not defined parent filechild file



Solution 1:[1]

Okay, so the issue is that you don't have a variable named currentnote anywhere in the Noteitem file. You need to have a variable named currentnote already defined to pass it through the function.

The function is throwing an undefined error because it cannot find the variable being passed to it.

Solution 2:[2]

In your child component:

const NoteItem = (props) => {
  const { buttonOnClickHandler } = props;

  return <button onClick={buttonOnClickHandler}>Click me</button>;
};

In your parent component:

<NoteItem buttonOnClickHandler={updateNote} />

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Omar
Solution 2 poliskalien