简体   繁体   English

出现“对象作为 React 子对象无效”的错误

[英]Getting error as “Objects are not valid as React child”

I'am working React weather project, in which by inputting the city and country values, the information is loaded on screen.我正在处理 React 天气项目,在该项目中,通过输入城市和国家/地区的值,信息会加载到屏幕上。 The amin file App.js is function component and getting above mentioned error after submitting the values. amin 文件 App.js 是 function 组件,提交值后出现上述错误。

Following are the files for reference以下是供参考的文件

  1. App.js (here getWeather() is created) App.js(这里创建了 getWeather())

在此处输入图像描述 2. Weather.js 2.天气.js 在此处输入图像描述 3. App.js (Component created here) 3. App.js(这里创建的组件) 在此处输入图像描述

  1. Error I'am getting我得到的错误

在此处输入图像描述

Aparently your 'city' props is a Object, not a String.显然,您的“城市”道具是 Object,而不是字符串。 take a console.log(city) to see what's inside.拿一个 console.log(city) 看看里面有什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM