我正在使用pern堆栈,当我尝试使用useEffect或useState时,我得到了这个错误。因此,我使用postgres创建数据库,使用express使用池进行连接
创建了一个端点,并尝试在我的代码中获取该端点
import React, {useEffect , useState} from 'react';
import Table from './Table';
import Nav from './Navi';
import TemplateList from './TemplateList';
import {Tab
我试图在我的功能组件中使用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
我使用的是react-router-dom。我需要重定向到仪表板时,用户注册成功。但是我的Redirect组件不工作。我该如何修复这个bug呢? 这是我的Register.jsx文件。 import React, { useState, useEffect } from "react";
import { Redirect } from "react-router-dom";
import Axios from "axios";
function Register() {
// Use state
const [name, s
错误:
React Hook "useState" is called in function "createFlight" that is
neither a React function component nor a custom React Hook function.
React component names must start with an uppercase letter react-
hooks/rules-of-hooks
我的代码:
import React, {Component} from 'react'
未立即更新React状态。我想在播放按钮上立即更新状态。
import * as React from "react";
import { Button } from "react-native";
export default function Play() {
const [player, setPlayer] = React.useState(1);
function nextPlayer() {
setPlayer(2);
updateValue();
}
function updateValue() {
if (
当我在另一个项目中使用相同的方法时,它运行得很好,但是我决定对我当前的项目使用相同的方法,然后我对下面给出的内容有了一个问题。
react-dom.development.js:14724 Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React a
我正在尝试使用编辑/删除资料表中的一行。虽然我可以看到状态正在被修改,但它不会重新呈现实体表。useeffect不是在setdata之后触发的。
import React, { useState, useEffect } from "react";
import faker from "faker";
import MaterialTable from "material-table";
import * as _ from "lodash";
let testData = [];
for (var i = 0; i <
我正在使用回调钩子来停止渲染组件,这些组件在每个渲染中都是由于作为道具传递的函数的更改而更改的。在这里,我向incrementSalary和incrementAge添加了回调钩子。在这种情况下,回调钩子似乎工作得很好。但是,eslint会抛出以下错误: Line 10:76: React Hook useCallback has an unnecessary dependency: 'age'. Either exclude it or remove the dependency array react-hooks/exhaustive-deps
Line 15
我正在尝试为我的组件创建一个SessionProvider来避免全局的propdrilling和hold session。 但是它说useSession不是一个函数,是什么给出的呢? contexts\SessionContext.js: TypeError: (0 , _hooks_useSession__WEBPACK_IMPORTED_MODULE_2__.useSession) is not a function 我的自定义钩子(useSession.js): import { useState } from 'react'
function useSession(
我已经尝试在我的文件中包含此代码,以便为我的react网站切换暗模式。但不幸的是,这段代码不起作用。我试图将代码放在渲染函数中,但它仍然显示此错误。有没有人能推荐一种更好的方式来写这段代码。
import React ,{useState} from 'react';
import styles from './App.module.css';
import titleImage from './images/image.png';
import { Paper ,Switch } from '@material-ui/c
我的应用程序接口遇到了一些问题,每次我登录并登陆我的Dashboard page时,它都会返回TypeError: Cannot read property 'data' of null的数据。这是一个使用JWT身份验证登录的简单应用程序,这意味着我需要在登录时在区域设置存储中设置令牌,我已经做到了。但是,令牌在15分钟后过期,需要刷新令牌。以下是该接口的详细信息:
Retrieve the necessary data for the dashboard at 'https://freddy.codesubmit.io/dashboard'.
This en
我刚开始使用react,我想为我的应用程序设置一个路由。我使用react-router-dom,我有一个连接组件和一个创建组件。我想在用户登录后在创建时重定向他。下面是我的代码: import React, { useState } from 'react';
import {
BrowserRouter as Router,
Switch,
Route,
Link
} from "react-router-dom";
import Aproove from "aproove/aproove";
import './A
我在尝试创建一个模式时出现错误。我尝试制作一个在单击按钮时出现的模式。这是一个在modal中弹出的表单,提交后modal将关闭。表单是一个常规组件,直到我更改了流程,所以我更改了组件,使其成为一个模式。在这样做之后,我得到了这个错误。
Error: Invalid hook call. Hooks can only be called inside of the body of a function component.
而且我的状态也不再起作用
Line 7:4: 'state' is not defined no-undef
提一下我还是个新手可能会更好。
这是我制