问题标签 [reagent-forms]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
reactjs - 自动完成问题(Material UI + React + Reagent/ClojureScript)
我在使用Autocomplete
带有 Reagent (ClojureScript) 的 Material UI 时遇到问题。该元素渲染得很好,但是当我尝试单击它时,出现以下异常:
打破 JS 调试器,我看到它inputRef.current
是 null (这是什么focus
并且removeAttribute
被调用。(奇怪的inputRef
是,文件中设置的唯一位置是调用useRef(null)
,这就是导致inputRef.current
为 null 的原因。)
在我的代码中,我将自动完成字段定义如下:
然后,在一个 React 组件中,它的使用如下:
(在这里,也以类似的方式a/text-field
在相同的命名空间中定义。)a/autocomplete-field
The JS console log (from the (js/console.log (clj->js params))
call) shows that inputProps.ref.current
is set to null. However, InputProps.ref
is not null. Even so, I tried to manually associate the same function as is passed with InputProps.ref
to inputProps.ref.current
, but that made no difference.
I have also tried the workaround suggested in https://github.com/mui-org/material-ui/issues/21245 (although that issue is with the Gestalt library, not with Reagent, it suggests that there may be a problem with ref forwarding). But wrapping the text-field
into a div with the ref
taken from InputProps.ref
also made no difference.
Any suggestions?