具有componentWillMount
异步行动的创建者需要时间来完成,处理渲染完成
同时,组件呈现一次或两次不提供,直到减速改变状态的数据,并包含它,
请澄清什么是处理初始组件渲染(S)有没有数据的最佳方式,
我发现自己做这样的事情:
render() {
if (!this.props.item) return <div></div>
// this fails during initial renders without the if condition above.
const { item: { foo: { bar } } } = this.props
}
我知道我可以在mapStateToProps
中拥有默认状态,但当实体(如item.foo.bar)具有嵌套字段时,这不起作用。
谢谢。