我想在前端显示帖子详情。我的 api 显示的帖子详情如下,在 postman 中捕获:"message": "Posts fetched successfully!","posts": {"_id": "61f05f676793d49f466e7aaa","title": "Liberal Arts Student Sample","content": "The three-page.","cre
2022-02-06
我正在尝试在 React 项目中编写一段 JavaScript 代码。我有一个组件“expenses”,它通过 props 传递了一些数据。数据是一些对象的数组。这是我的代码:数据:const EXPENSES = [{ id: "e1", date: "March 2021 12", description: "New TV", price: "$780" },{ id: "e2", date:
2022-02-01
我尝试在 App.js 中迭代我的 React 应用的 firebase db 变量,但遇到了一些问题。这是我一直在观看的视频 - 大约 1 小时 9 分钟https://www.youtube.com/watch?v=f7T48W0cwXM&t=44s所以基本上他们导入并设置了他们的 firebase.js。我的看起来有点不同,因为自视频发布以来语法已经发生了变化。我的 firebase.js
2022-01-27
尝试使用 react native reanimated 中的插值时出现错误。当不透明度从 1 更改为 0 时,我希望我的按钮平移到负 Y 轴。我看过一些关于此的教程,但有点过时了。我能够查看文档,我做的一切都是正确的。我不知道我的错误在哪里。请看一下:import { TapGestureHandler,State } from 'react-native-gesture-handler';im
function Screen2({route, navigation}) {return (<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}><Text>{route.params.myText}</Text></View>);}export default Screen2;这里的 myText 是
2022-01-23
我在传递 props 对象时遇到问题,第二页显示未定义。我尝试在第一页使用console.log(databaseObject?.points[0].questions)正确传递它,并且它是我想要的,但是当我尝试在第二页接收它时,它总是未定义。我在接收 props 时遗漏了什么吗?在第二页上,我从console.log(props.questions)得到了 'undefined',从consol
2022-01-16
我在使用 Redux Toolkit 时遇到了问题。我想将一个称为 selectedData 的对象推送到我的初始状态,这是一个数组,这给了我错误“TypeError:undefined 不是对象(评估‘state.selectedData.push’)”。我一直在关注https://redux-toolkit.js.org/usage/immer-reducers,他们编写的 Reducer 逻
2022-01-05
我正在创建一个表单来更新应用程序后端的患者对象。当我提交表单时,它给了我“TypeError:无法读取未定义的属性(读取'firstName')”,然后显示此信息72 | && <p className={styles.errMsg} name="errMsg" data-testid="errMsg">{constants.API_ERROR}</p>}73 | {patient && (7
2022-01-02
当我尝试访问从数据库中提取的数据(receivedData 是一个对象)时,我收到TypeError:无法读取未定义的属性(读取“0”)。我已尝试console.log我的receivedData,它确实有数据。以下是我的social结构,它是我的receivedData 对象的键之一。const logoObj = {"telegram": telegramWIcon,"twitter": tw
2021-12-25
我最近升级到了 webpack 5.65.0。这破坏了 @react-pdf/renderer。GitHub Issue 上的一个answer有我正在尝试实施的修复。尝试“修复”后,我得到了与此 SOQuestion完全相同的错误,只是解决方案不适用于我。...../node_modules/webpack/lib/NormalModule.js:1349hash.update(this.buil
2021-12-20
我在 React 组件中有一个渲染匹配名称的代码。但有时当前匹配有空对象,我无法通过此问题。组件代码:import React from 'react'import {Link} from 'react-router-dom'export const MatchList = ({ links }) => {if (!links.length) {return <p className="cent
2021-12-15
import React, {useState, Component, useMemo} from 'react';import { StyleSheet, Text, View, Button, TextInput, Image } from 'react-native';import { NavigationContainer } from '@react-navigation/native'
2021-12-14
我是 react-native 的新手。为了学习,我创建了一个示例项目。我想通过按下抽屉内的文本导航到另一个页面。所以我遇到了错误TypeError: undefined is not an object (evaluating '_this.props.navigation.navigate')我添加了示例代码import React,{Component} from "react";impor
我正在使用Ractjs,Mongoose,GraphQl和Apollo创建社交媒体。当我尝试从DB获取数据以显示在主页上时,我会遇到一个错误,说typeError:无法读取未定义的属性(读取'getPosts')。我搜索解决方案并尝试了很多事情,什么也没有奏效文件structre-client----- node_modules----- public---- src-------组件------
我尝试从 API 获取数据并在我的应用中使用该数据。但问题是,当我尝试从刚从 API 获得的 JSON 中获取某个对象或数据时,我收到 TypeError:无法读取未定义的属性“country”。该属性确实存在。顺便说一句,我正在使用 React.js。非常感谢您的帮助和指导。这是代码:App.js{typeof weather != 'undefined' ? (<div><div classN
2021-12-06