5

したがって、署名component-will-receive-propsは次のとおりです。

https://github.com/reagent-project/reagent/blob/master/src/reagent/core.cljs#L114

:component-will-receive-props (fn [this new-argv])

しかしnew-args、それは関数またはjsオブジェクトのようです。私はそれが小道具の地図であることを期待していました。から小道具のマップを取得するにはどうすればよいnew-argvですか? から古い小道具を入手できますthis(reagent/props this)、それは古い小道具であり、新しく受け取ったものではありません。

4

2 に答える 2

4

わかりました、ついにそれがわかりましたreagent.impl.util/extract-props。したがって、(reagent.impl.util/extract-props new-argv)新しい小道具が返されます。

https://github.com/reagent-project/reagent/blob/v0.5.1-rc3/src/reagent/impl/util.cljs#L11

于 2015-09-11T20:30:30.187 に答える
1

これを行う正しい方法は props 関数を使用することだと思います。ここに例を示します。

;; assuming you have reagent required :as reagent

(reagent/create-class
  {
  ...

  :should-component-update
  (fn [this]
    (println "next-props" (reagent/props this))
  ...
  })
于 2015-12-07T21:50:57.313 に答える