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> } }