【问题标题】:React Error: Objects are not valid as a React childReact 错误:对象作为 React 子对象无效
【发布时间】:2020-12-03 21:15:04
【问题描述】:

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

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)

注册和其他页面对我来说都很好,所以我想知道我在登录时搞砸了什么。

【问题讨论】:

  • pastebin.com/zvCjzJag是login.component.js的代码
  • 看起来您正试图将一个对象渲染为一个反应组件...如果没有看到导致此问题的代码,我们将无法为您提供更多帮助。尝试制作一个可重现的小例子并在这里分享
  • 请在您的问题中显示您的代码。
  • @Aza 您能否编辑您的问题并将其包含在此处而不是场外

标签: node.js reactjs


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2018-11-12
    • 2021-08-05
    • 2021-08-20
    • 2016-10-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-18
    • 1970-01-01
    相关资源
    最近更新 更多