我使用React钩子来表示状态,但是当我使用useState时,它显示了一个错误,即:
Compiled with problems:X
ERROR
src\Form.js
Line 9:29: React Hook "React.useState" is called in function "form" that is neither a React function component nor a custom React Hook function. React component na
在导入Imex之前,该应用程序运行良好,没有任何错误,它显示了4个错误,如下所示
1. Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
You likely forgot to export your component from the file it's defined in, or you might have mixed up
我正在构建一个石头/纸/剪刀反应应用程序,但当我试图做出选择(石头、剪刀或剪纸)时,我遇到了问题,保存了选择的价值并将其显示在屏幕上。我已经设法将用户选择的所有值都console.log了,但是我不知道如何将它们传回我的选项组件,并在屏幕上看到它。
你能帮我解决这个问题吗?
非常感谢!
Main.js
import React from "react"
import Choice from "./Choice"
import paper from '../images/icon-paper.svg'
import rock from '
我试图在我的功能组件中使用React useState钩子,但是我得到了这个错误:
Failed to compile
./src/Person/Person.js
Line 5:43: React Hook "useState" is called in function "person" which is neither a React function component or a custom React Hook function react-hooks/rules-of-hooks
Search for the keywords to le
在我的项目中,我希望在链接标记中显示产品图像,这样在单击图像之后,我就可以显示有关产品的详细信息,但是在ProductScreen中使用Link或Navlink之后,我将获得空白页面显示。
HomeScreen.js
import React, { useEffect } from "react";
import Products from "../Product.js";
import { Row, Col } from "react-bootstrap";
import ProductScreen from "./ProductScr
我是非常新的反应,我试图使我的删除和编辑按钮工作。但是它给了我一个错误"TypeError: props.onDeleteClick不是一个函数“
import React from "react";
import Person from "./Person";
import * as UserService from "../services/userServices";
class People extends React.Component
{
state = {
template: [],
我刚刚开始用TypeScript编写反应测试代码,
Login.test.tsx
import React from 'react';
import { shallow } from 'enzyme';
import Login from './Login';
describe('Login', () => {
const login = shallow(<Login />);
});
Type '{}' is missing the following properties f
我正在使用Next.js的最新版本来制作我的博客网站,不知道为什么显示错误,当我试图制作我的表单时,然后显示我的错误,就像这样: Warning: Function components cannot be given refs.
Attempts to access this ref will fail. Did you mean to use React.forwardRef()? ? 我在下面的代码中尝试过: import React, { useState } from "react";
import { APP_NAME } from "../
我正在尝试自己做一个小项目来了解React-Native。 我有两个屏幕,我想通过按下按钮从我的SplashScreen导航到HomeScreen。但它给了我一个错误。我应该添加什么来消除这个错误? 以下是代码App.js import 'react-native-gesture-handler'; // react-navigation, must be on top
import React from 'react';
import { NavigationContainer } from '@react-navigation/native
学习typescript并尝试将我的另一个react项目转换为typescript来学习它。 我在我的App.tsx文件- Type '{ history: History<unknown>; location: Location<unknown>; match: match<any>; staticContext?: StaticContext | undefined; }' has no properties in common with type 'IntrinsicAttributes'.中收到有关路由的错误 nam
我正在尝试创建一个表单Redux-Form6.6.3,使用类型记录2.3并作出反应。我已经安装了类型定义@type/redux-form 6.6.2。这是表格:
import * as React from 'react';
import { reduxForm, Field } from 'redux-form';
import styles from '../../styles/styles';
class CreateFunction extends React.Component < any, any > {
priva
希望有人能帮我,因为我在努力看问题出在哪里。
当使用react本机导航创建堆栈导航器时,无论我使用何种方法导出和导入组件以传递到<Stacks.creen/>,它似乎都会抛出以下错误。
堆栈跟踪
Error: Couldn't find a 'component', 'getComponent' or 'children' prop for the screen 'Home'. This can happen if you passed 'undefined'. You likely forg
我是新的反应-本机,我正面临上述错误在我的代码。
我面临的错误是:
TypeError:未定义不是对象(计算'name.length')
此错误位于:
in ProductCard (created by ProductList)
in RCTView (created by View)
in View (created by ProductList)
in RCTView (created by View)
in View (created by AnimatedComponent)
in AnimatedComponent
in AnimatedComponentWrapp
我正在学习React和Redux,当我这样做的时候,我决定制作一个带有按钮的网页,点击按钮就会改变状态。在按钮下面,我想在另一个组件中显示当前状态。虽然单击按钮会更改状态,但它不会反映在组件中。下面是我的代码:
App.js
import React from 'react'
import Name from './Name'
import {changeName} from './Action';
export default function App () {
return (
<div>