首页 > 解决方案 > React 错误:对象作为 React 子对象无效

问题描述

我试图创建一个登录页面,这就是我在尝试登录时遇到的错误。我试图解决它,但我没有找到任何解决方案。

Error: Objects are not valid as a React child (found: object with keys {}). If you meant to render a collection of children, use an array instead.
    in div (at login.component.js:136)
    in div (at login.component.js:135)
    in form (created by t)
    in t (created by Form(t))
    in Form(t) (at login.component.js:92)
    in div (at login.component.js:85)
    in div (at login.component.js:84)
    in Login (created by Context.Consumer)
    in Route (at App.js:140)
    in Switch (at App.js:131)
    in div (at App.js:130)
    in div (at App.js:52)
    in App (at src/index.js:10)
    in Router (created by BrowserRouter)
    in BrowserRouter (at src/index.js:9)

注册和其他页面对我来说工作正常,所以我想知道我在登录时搞砸了什么。

标签: node.jsreactjs

解决方案


您尝试渲染一个对象。尝试Object.values(myObj)


推荐阅读