我想知道我怎樣才能在這種情況下,我的子元素的狀態,請如何在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>
)
}
}
請詳細說明一下你爲什麼需要這個。你在努力達到什麼目標? –