具有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)具有嵌套字段時,這不起作用。
謝謝。