1

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

我觉得是re-frame/as-elementfn?

由于 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)]))

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

4

1 回答 1

0

在这段代码中,render 函数并不清楚。为了发生重新渲染,订阅应该在渲染函数内。我仍然建议将其包装在 a(fn [])中并删除(re-frame/as-element).

于 2019-08-09T08:33:18.237 回答