Search code examples
clojurescriptreagent

Reagent: How to get new props from component-will-receive-props?


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.


Solution

  • 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