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.
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
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))
...
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With