开发者问题收集
我有一个 Article 组件和一个包含我所有文章的状态。我将状态映射到我想要显示的正确文章的 props。console.log(props.article)有效,但console.log(props.article.title)或任何其他属性无效(我得到无法读取未定义的属性“id”)。为什么?我的Article.js组件:从“react”导入 React;import { connect }
从 GamePage 开始,它提供了 2 个路由,分别呈现组件 GameList 和 GameDetailPage。两者最初都运行良好,但当我刷新 Gamelist 组件的页面时,它仍然会重新呈现该页面,但当我刷新 GameDetailPage 的页面时,我收到错误 TypeError:无法读取未定义的属性“Location”。我不明白为什么每次刷新时都无法从状态中获取数据。gamepage.js
在操作“ADD_CONTACT”之后,新状态在 redux 中得到更新,但即使我使用扩展运算符添加初始状态,初始状态也不会反映出来。这是我的 Reducer:const initalstate = {information : [{key: 1,name: "firstname"}]}export const productReducer = (state = initalstate, act
我在 React 中实现了一个小测试应用程序来通过 AJAX 获取数据,但它没有按预期工作,因此我收到以下错误:Uncaught TypeError: Cannot read property 'map' of undefinedInline JSX script代码如下:<div id="content"></div><script type="text/jsx">var Bodypart =
我试图使用 json 返回的内容不仅填充我的列表,而且在创建新列表时允许选择父级。我的导航中出现了列表,但是当我单击“创建新列表”时,它会出现以下错误:Uncaught TypeError: Cannot read property 'map' of undefined这发生在代码的这一特定部分:render: function() {var navNodes = this.props.data.
我刚刚开始使用reactjs并进行教程。本教程似乎不是完全最新的。我总是收到此错误消息:Uncaught TypeError: Cannot read property 'map' of undefinedat ContactsList.render (ContactsList.js:40)at ReactCompositeComponent.js:796at measureLifeCyclePe
我正在遵循 ReactJSAJAX 和 API 教程。我在 Spring 中编写了一个简单的 API,然后编写了一个 React 组件以在http://localhost:8080上使用该 API。API 当前返回两个项目的列表,如下所示:[{brand:"Asus", make:"AAA"},{brand:"Acer", make:"BBB"}]这是我的组件的样子:import React fr
我正在学习 React JS 教程,并尝试将 props 从一个组件传递到另一个组件,以便呈现曲目列表。我查看了一些有类似问题的线程,但没有任何建议可以解决我的问题,我不知所措。我怀疑这个问题与我的初始状态设置方式有关。我尝试了以下操作。无法读取未定义 REACT 的属性“map”按照上述建议,在接收组件时将“this.props”更改为“this.state”,反之亦然,但这并不能解决问题,只会
我正在按照在线教程学习有关 React.js 的受控输入,但不断收到错误TypeError: Cannot read property 'map' of undefinedimport CallRow from "./CallRow";import React from "react";class SearchPage extends React.Component {constructor()
我之前也做过类似的事情(在网格中显示项目),所以我尝试遵循该模式。我盯着这个看了一段时间,想找出问题所在。是不是有什么我没看到?帮助错误消息 9 | console.log(localStorage.getItem("shoppingCart")),10 | <div>11 | <Grid container spacing={3}>> 12 | {items.map((item)
我正在尝试使用commerce.js库创建一个电子商务网站。库 API 中已经有 8 种产品。我有一个Products.js组件,我将从App.js获得的产品对象数组传递给Product.js组件。为此,我使用映射函数将每个对象作为 props 传递给Product.js组件。但我收到了此错误。我尝试注释掉映射块,并且只有控制台记录了来自App.js的products变量和Products.js中
我遇到了错误TypeError: 无法读取未定义的属性(读取“地图”)此代码应返回卡片标题中的城市名称,该名称已在我的其他文件中定义,但引发了错误。代码:import React, {Component} from 'react';import Body from './Body';class Weather extends Component {constructor(props) {super
我有一个 React 应用,但无法深入了解状态。import React, { Component } from 'react';import { Grid} from 'react-bootstrap'import fetch from 'isomorphic-fetch';class Pokemon extends Component {constructor(props) {super(pr
当用户点击select框时,我想通过 AJAX 请求将所有公司加载到state属性中。这是代码:import React, { Component } from 'react';import SelectOption from './SelectOption';class CreateFreightEntryModal extends Component {constructor(props) {
尽管在使用 setState 时使用了粗箭头函数绑定 this 的上下文,但我仍不断收到此错误。有人可以帮忙吗?export default class App extends Component {constructor(props) {super(props);this.state = {query: '',items: [],repos: []};}search(term) {this.se