1

これは一般的な質問です。x分ごとにストアを更新し、redux devツールでストアが適切に更新されることを示す呼び出しを生成するredux sagaがあります。コンポーネントのrenderメソッドで、データの前にクリックするとスピナーが表示され、コンポーネントがレンダリングされた後にクリックすると; ただし、コンポーネントクラスでは、ライフサイクル「componentWillUpdate」または「componentWillReceiveProps」は、reduxストアの接続されたピースをどちらのメソッドでも未定義として示しますが、レンダリングは正しい小道具を渡すことができます。何の音?ドキュメントに戻りますが、これは奇妙に思えます。

...
    //dont usually use this for redux
    componentWillReceiveProps(){
      console.log(dailyOperations) // nothing here
    }

    componentWillUpdate(){
      console.log(dailyOperations) // nothing here
    }

    render(){
      if (dailyOperations === undefined) {
        return (<SpinnerThing />)
      else
        return (<SomeDisplayComponent data={dailyOperations} />)  //Data is here
    }

ここに画像の説明を入力

4

1 に答える 1

0

当時は説明できませんでしたが、今ではそれが理にかなっており、それが他の誰かに役立つなら. 接続されたredux状態の更新にはありませんが、「componentWillUpdate(nextProps)」とnextPropsを介してそれがあります。

于 2016-09-16T14:36:12.583 に答える