reagent

A minimalistic ClojureScript interface to React.js http://reagent-project.github.io/
Chris McCormick 2020-07-16T01:16:21.038500Z

https://google.github.io/closure-library/api/goog.functions.html#debounce

đź‘Ť 2
johnnyillinois 2020-07-16T06:32:42.041800Z

This might be a noobie question but I’m wondering what would be the “recommended way” to create a reagent component which “takes as input” 2 other components and displays one or the other depending on some internal state. For example:

(defn hello-a [] [:div "a"])
(defn hello-b [] [:div "b"])

(def possibly-true? (zero? (rand-int 2)))

(defn choose-a-or-b
  [{:keys [view-1 view-2]
  (if possibly-true?
    [view-1]
    [view-2]))

(defn home-page
  []
  [choose-a-or-b {:view-1 hello-a :view-2 hello-b}])

p-himik 2020-07-16T06:38:02.042200Z

Your code is just fine. A regular HOC.

johnnyillinois 2020-07-16T06:49:50.042400Z

🙌