基本的渲染道具翻译成试剂

因此,我正在尝试使用试剂渲染MUi自动完成功能。这是我的尝试

database

我尝试将其直接传递为(def options (clj->js [{:title "title" :year 1990} {:title "title2" :year 2990}])) (defn autocomplete-text-field [] [:> TextField {:label "Headers" :id "header" :variant "outlined" :fullWidth true } ] ) (defn add-header-form [] [:> Card {:style #js {:max-width 1000}} [:> CardHeader {:title "Add Header"}] [:> CardContent [:> Grid {:container true :direction "column"} [:> Autocomplete { :renderInput (r/reactify-component autocomplete-text-field) :options options :getOptionLabel #(get % :year)} ] ] ]] ) ,但无法弄清楚。我正在尝试翻译Mui页面中的示例:

https://material-ui.com/components/autocomplete/

编辑

:renderInput autocomplete-text-field

那么我该如何为那个renderInput属性编写等效的试剂代码呢?

谢谢。

yonghengwupan 回答:基本的渲染道具翻译成试剂

renderInput需要一个返回React元素的函数。

您可以在reagent中通过

进行操作
:renderInput (fn [params] (r/as-element [autocomplete-text-field params]))

params很可能是一个JS对象,这意味着您可能需要一些JS互操作才能将任何道具应用于文本字段。不知道它会通过哪种params

本文链接:https://www.f2er.com/3160090.html

大家都在问