Reagent: How to get new details from third-party suppliers?

Thus, the signature for component-will-receive-propsis:

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

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

But new-argsit looks like a function or js object. I expected this to be a props card. How to get a props card with new-argv? I can get the old details from thison (reagent/props this), but these are old details, not new ones.

+4
source share
2 answers

Ok, I found out about it reagent.impl.util/extract-props. Thus, (reagent.impl.util/extract-props new-argv)will return new details.

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

+3
source

, - . .

;; assuming you have reagent required :as reagent

(reagent/create-class
  {
  ...

  :should-component-update
  (fn [this]
    (println "next-props" (reagent/props this))
  ...
  })
+1

Source: https://habr.com/ru/post/1607022/


All Articles