gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 22:47:30 24 4
gpt4 key购买 nike

我有以下代码来测试 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 .

最佳答案

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

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

关于clojurescript - 即使 :component-did-update is called,form-3 组件也不会重新呈现任何内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57657560/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com