我想知道我怎样才能在这种情况下,我的子元素的状态,请如何在ReactJS中获取我的子元素的状态?
class Child extends React.Component{
constructor(props){
super(props)
this.state = {
element : "I NEED THIS STATE"
}
}
render(){
return <h1>Hello</h1>
}
}
class Main extends React.Component{
render(){
return(
<div>
<Child />
</div>
)
}
}
请详细说明一下你为什么需要这个。你在努力达到什么目标? –