如何在ClojureScript中重新渲染重新框架的元素?

时间:2019-08-09 07:57:56

标签: clojure clojurescript reagent re-frame

:link-flows子项已更改,@(subscribe [:link-flows ::assign-to-flow-q])未触发且重新渲染不运行时,我具有此代码块。

我认为是re-frame/as-element fn吗?

由于React子表错误,还包装到(fn [])中会引发错误,因此这不是一个选择。

Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it.

(let [flows @(subscribe [:link-flows ::assign-to-flow-q])]
  (re-frame/as-element
    [ant/select
     {:showSearch       true
      :optionFilterProp "children"
      :onSearch         #(dispatch [:set-ns-search-q ::assign-to-flow-q %])}
     (map (fn [flow]
            [ant/select-option
             {:value (:id flow)} (:name flow)])
          flows)]))

有什么办法可以使这种重新渲染机制起作用?

1 个答案:

答案 0 :(得分:0)

在此代码中,渲染功能不清楚。为了进行重新渲染,订阅应位于渲染函数内部。我仍然建议将其包装在(fn [])内并删除(re-frame/as-element)