我在Javascript/React中看到了很多类似的问题,但是我在CLojureScript/Reagent中遇到了这个问题,我不知道如何解决这个问题,而不会混淆我所有的应用程序状态名称。
因此,我在浏览器控制台中得到了这些警告:
react_devtools_backend.js:2430 Warning: React does not recognize the `showWarning` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `showwarning` instead. If you accidentally passed it from a parent component, remove it from the DOM element.它们似乎来自于应用程序状态中某个项目的名称:
(defonce app-state (reagent/atom {:show-warning "none"}))我找到的唯一解决方案是将项目从:show-warning重命名为:show warning,但这会导致一堆难以阅读的项目。
对于Reagent如何将键重命名(如:将警告显示为"showWarning“),我没有任何真正的控制,但似乎这是React工作方式的基础,它将有一个更干净的方法来处理这个问题。
谢谢!
发布于 2021-02-12 15:05:29
反应真的不应该看到你的状态或关心它里面是什么。我猜你会把你的状态放在道具的某个位置。很可能在代码中的某个地方有[:div @app-state]。可能你是在尝试渲染状态,并且应该做[:div {} @app-state]。
对于Reagent来说,这可能有点麻烦,因为[:p @im-a-string]会呈现字符串,但是[:p @im-a-map]会把映射当作道具。
https://stackoverflow.com/questions/66161430
复制相似问题