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!