-1
我有一個問題..如何將狀態發送到條件組件?
請幫助我。
我的工作反應JS
如何發送的狀態條件發生反應成分?
this.state = {
isTrue: false,
name: undefined
}
handleClick(e){
this.setState({
isTrue: true,
name: 'adwin'
})
}
//////// render return ///////
{this.state.isTrue ? (
<App2 name={this.state.name} />
) : ''
}
////// in App2 component //////
componentDidMount(){
console.log(this.props.name) //>>> it work undefined
}
這不是在所有清楚你在問什麼。請使用Stack Snippets('[<>]'工具欄按鈕)使用** runnable ** [mcve]更新您的問題。 Stack Snippets支持React,包括JSX; [這是如何做一個](http://meta.stackoverflow.com/questions/338537/)。 –