开发者问题收集
我在使用 React 表单和正确管理状态时遇到了麻烦。我在表单(在模态框中)中有一个时间输入字段。初始值在getInitialState中设置为状态变量,并从父组件传入。这本身工作正常。当我想通过父组件更新默认的 start_time 值时,问题就出现了。更新本身通过setState start_time: new_time在父组件中发生。但是在我的表单中,默认的start_time值永远不会改变
刚接触 React,正在尝试使用它。看不出使用 forEach 时出现错误而使用 map 时没有错误的任何明显原因:注意:我将其与 ampersand(基于骨干的框架)一起使用Repos = 30 个对象,每个对象有 3 个属性export default React.createClass({mixins: [ampersandReactMixin],displayName: 'ReposPag
我正在使用 Reactjs 并使用 nextjs 框架,现在我正在尝试使用 map 函数获取数据(url 是 -https://dummyjson.com/products)但我收到以下错误TypeError: Cannot read property 'length' of undefined这是我当前的代码import { useEffect, useState } from "react"e
我试图在 codesandbox 中编写代码,但出现错误。我必须通过三元组进行检查。TypeErrorCannot assign to read only property 'message' of object 'SyntaxError: /src/components/SearchResults.js: Unexpected token (8:10)6 | {filteredPro
我正在使用 Jest 测试 React 组件。我正在尝试模拟来自其他依赖项的函数。依赖项中的函数应该返回一个数组,但它在控制台上显示未定义。下面的文件是 tsx 文件,当我单击按钮时,它应该调用依赖项函数来获取框架列表。ExitAppButton.tsx:import React, { useContext, useState } from 'react';import { TestContext
有人知道这个错误的原因吗?warn - Fast Refresh had to perform a full reload. Read more: https://nextjs.org/docs/basic-features/fast-refresh#how-it-worksTypeError: Cannot read properties of null (reading 'length')a
我尝试将类函数文件转换为钩子函数,但每当在字段中输入文本时都会出现以下错误。Unhandled Runtime Error TypeError: Cannot read properties of undefined (reading 'length')我想我已经转换了所有内容,但就是找不到是什么 - 我遗漏了什么吗?新的钩子代码出现上述错误:import React, { useState }
从 API 获取数据时,我在 equipmentExercises 块中收到此错误。我已经检查了数据类型,它是一个数组。并且 equipmentExercises.length 显示未定义的数据类型。const SimilarExercises = ({ targetMuscleExercises, equipmentExercises }) => {console.log(equipmentEx
我正在制作一个电影应用程序克隆,但出现了这个错误:"Unhandled Runtime Error TypeError: Cannot read properties of undefined (reading 'length')"错误截图import Image from 'next/image'import { useEffect, useState } from 'react'import
我在nextjs文件中遇到了这样的错误: 117 | };118 |> 119 | if (data.length <= 0) {| ^120 | return null;121 | }122 |如果我想用照片展示的话,如下:这个项目在不同的电脑上都能运行,但是在我电脑上不行,这个错误该怎么解决?我每次刷新页面也会遇到不同的错误。17354 | R
import React from 'react';import {MinCont} from "./MinCont";export const Contain = (props) => {let myStyle = {minHeight: "100vh",margin: "40px auto"}let empty = {color: "red",}return (<div className="
const Cart = ({ cartItems }) => {return (<div className="cart-items"><div className="cart-items-header">Cart Items</div>{cartItems.length === 0 && (<div className="cart-items-empty">No items are added
我无法访问使用 redux 检索的数组中的项。当我在操作本身中执行控制台日志时,我可以单独访问数组元素。但是,一旦该数据在操作分派后进入组件进行显示,我就无法正确解析数据结构。ListingActions.js:如果我在此处执行控制台日志,我可以毫无问题地解析变量数据的不同索引export const getListings = () => async (dispatch) => {try {di
我现在已经努力尝试将数据放入表格中一段时间​​了。我尝试了不同的方法,以最简单的方式从后端获取数据。最新的尝试在console.log(tableData)中给出了这个:(3) [{…}, {…}, {…}]0: period: "23"periodId: 1periodQuantity: Array(3)0: {period: "23", quantity: 1037, name: "Stolp
我正在使用 TMDB,并尝试显示评分最高的电影的图片(海报),但什么都没显示。我在控制台中检查是否有元素,结果有,但什么都没显示。我按照此视频进行了说明,但我不知道为什么它对我不起作用:https://www.youtube.com/watch?v=sZ0bZGfg_m4这是我当前的代码:App.js:import {useEffect, useState} from 'react';import