Fork me on GitHub
#reagent
<
2023-03-20
>
Clojuri0an08:03:41

I'm having trouble understanding why this does not call [payment-entry] 3 times

defn payment-entry []
    [:div {:class ["form-window-visible"]}
  [:p {:id "payment-date:" :class ["bg-blue-50"] } "payment date " name]
   [:p {:id "payment-amount"} "amount test: " name]
   [:p {:id "payment-receipt"} "receipt: "name]
   ;; this is a url
   [:p "test" ]])
(defn invoice-container-tree [invoice-title name items]
  [:div {:id "tree-invoice" :class ["form-window-visible"]}
   [invoice-id-and-num]
   [:p {:class ["text-basic"]}  "this is a test of the description and how it will look"]
   [:p {:class ["text-basic"]} "Current balance: " name]
   [invoice-payment-make]
   [:button {:class ["button-basic" "p-3"] :on-click #(swap! is-show-form not)} "View past payments"]
   (if  @is-show-form
     [invoice-payment-previous])
   (if (and @is-show-form @is-show-p1)
        (for [item items] [payment-entry]))])


;; need 

(defn childcaller []
  [invoice-container-tree "Example-Project" "invoice-container-tree" (range(3))])
if the (for [item items] is placed in front of each [:p of payment-entry, then it will print the (range(3)) for each, but my goal is to print the component 3 times (one for each previous payment, assuming there are 3 previous payments). Putting the for in front of [:div returns a react error

2
p-himik09:03:37

Your code shouldn't work at all because (range(3)) is not a valid expression. It should be (range 3).

2
Clojuri0an11:03:07

Thanks once again. Child-container wasn't being called by mountit. It worked as intended fixing range and calling it correctly. I apologize for posting something I could have probably caught if my linter was on, need to configure it

👍 2