0

I want to pass data from a child component to the parent

const Main () => {
    const helloUser(name) => console.log("hello, name)
    return <User helloUser={() => helloUser } />
}

const User (props) => {
    const { helloUser } = props
    helloUser("john")
    return <p>User component</p>
}

it doesn´t work. it only works If i pass the data like this in the Main component

return <User helloUser={() => helloUser("john") } />

what I´m doing wrong? thank you!

handsome
  • 2,335
  • 7
  • 45
  • 73

1 Answers1

0

I was incorrectly passing () =>

return <User helloUser={helloUser } />
handsome
  • 2,335
  • 7
  • 45
  • 73