即使调用:component-did-update,form-3组件也不会重新呈现任何内容

时间:2019-08-26 12:00:54

标签: clojurescript reagent

我有以下代码来测试Form-3组件:

(defn inner [data]
  (reagent/create-class
   {:display-name "Counter"

    :component-did-mount (fn []
                           (js/console.log "Initialized")
                           [:h1 "Initialized! " data])


    :component-did-update (fn [this _]
                            (let [[_ data] (reagent/argv this)]
                              (js/console.log (str "Updated " data))
                              [:div (str "My clicks " data)]))

    :reagent-render (fn [] [:div (str "My clicks " data)])}))

由于控制台日志中有预期的输出,因此我能够成功触发:component-did-mount:component-did-update。但是,这两个功能实际上都不会更改页面上的任何内容。它只是始终显示[:div (str "My clicks " data)]的初始状态。

我在做什么错?附言我已经阅读了reagent docspurelyfunctional guide

1 个答案:

答案 0 :(得分:2)

您必须在:reagent-render函数中repeat the parameters

(fn [data] [:div (str "My clicks " data)])