1.直接在子組件中使用(不推薦)
class child extends component{
render(
<div>{this.props.value}</div>
)
}
2.自己在構造函數中初始化一個值,在將 status 通過 componentWillReceiveProps 生命周期方法 更新(轉換為子組件的state)
class Child extends Component { constructor(props) { super(props); this.state = { someThings: props.someThings }; } componentWillReceiveProps(nextProps) { this.setState({someThings: nextProps.someThings}); } render() { return <div>{this.state.someThings}</div> } }