【发布时间】:2020-04-29 12:56:47
【问题描述】:
我想将数据从子组件传递给父组件
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>
}
它不起作用。它只有在我在主组件中传递这样的数据时才有效
return <User helloUser={() => helloUser("john") } />
我做错了什么?谢谢!
【问题讨论】:
标签: javascript reactjs