我有以下代码来测试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 docs和purelyfunctional guide。
答案 0 :(得分:2)
您必须在:reagent-render
函数中repeat the parameters:
(fn [data] [:div (str "My clicks " data)])