5

So signature for component-will-receive-props is such:

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

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

But new-args seems like it's function or js object. I was expecting it to be map of props. How do I get map of props from new-argv? I can get old props from this by (reagent/props this), but it's old props, not newly received.

ma2s
  • 1,312
  • 1
  • 11
  • 24

2 Answers2

4

Ok I finally found out it's reagent.impl.util/extract-props. So (reagent.impl.util/extract-props new-argv) will return new props.

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

ma2s
  • 1,312
  • 1
  • 11
  • 24
1

I think the correct way to do this is through the props function. An example here shows this.

;; assuming you have reagent required :as reagent

(reagent/create-class
  {
  ...

  :should-component-update
  (fn [this]
    (println "next-props" (reagent/props this))
  ...
  })
Jon Rose
  • 1,457
  • 1
  • 15
  • 25