Unhandled Rejection (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 and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3
我有一个 and表单,当我按下提交按钮时,就可以在onFinish function中获取表单数据,在该按钮中,我希望使用uesEffect hook,并将表单数据作为有效负载分派到redux中,但我得到了以下错误
React Hook "useEffect" is called in function "onFinish" that is neither a React function component nor a custom React Hook function.
如果我在onFinsh 函数之外编写useEffect钩子,则无法获得表单数据/值。
错误:
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'
当我在我的应用程序上使用钩子时,我得到了的错误:无效的钩子调用。我不知道为什么要得到这个错误,因为我认为它是在函数组件中调用的?
Server Error
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 and the renderer (such as R
我有错误说
react.development.js:1476 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 and the renderer (such as React DOM)
2. You might be breaking th
import {useState} from 'react'
const nav = () => {
const [activeNav, setActiveNav] = useState('#')
}
我想建个导航吧。我搞错了,我不知道为什么
React Hook "useState" is called in function "nav" that is neither a React function component nor a custom React Hook function. React compone
我在React Native应用程序中尝试获得准确的计时时遇到了一个问题。下面是我的问题的一个基本版本。 我可以通过使用setTimeout让它工作,但是它不准确,我正在尝试使用useTimer,这是一个精确的计时器。但是,当我在useEffect中而不是在组件主体中创建计时器时,我得到了一个Invalid Hook Call, Hooks can only be called inside the body of a function component 正在努力寻找解决这个问题的方法。 import React from "react";
import { View, T
错误
这是浏览器在网页上显示的错误。
Compiled with problems:X
ERROR
src\components\SignIn.js
Line 5:21: React Hook "useRef" is called in function "signin" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React
当我想在customHook代码中设置if时出错
在这之后我得到了错误的->
React Hook "" is called conditionally. React Hooks must be called in the exact same order in every component render
问题是,在称此工作为好(不包括if ) ->时,是否存在状态
const =(,());
如果useDataForm (自定义钩子) dataValid无效,则不加载。
我有一个简单的注册表单,并使用react-hook-form和react-router。我想在Axios post请求之后在onSubmit内重定向。我不能让它发生,我在网上找不到任何解释原因的东西。
我试过redirect和useNavigate都来自react-router。在使用redirect时没有发生任何事情,我在使用navigate时会得到这个错误
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for o
我不知道为什么在通过React查询使用突变时会出现这个错误。任何形式的反馈都将不胜感激。
注意:我在一个函数(React)组件中使用,所以我不知道为什么会抛出这个错误。
错误:
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 and the renderer (such
当我在我的应用程序中输入内容UI代码并在浏览器上启动我的react应用程序时。我的应用程序警告:
22. Stack frames were collpsed.
-------------------------------
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
我有一个函数,每次名称状态改变时都会调用该函数。我想把这个更改后的值发送给父组件,但它指出了这个错误:
React Hook "useEffect" is called in function "handleNameChange" which is neither a React function component or a custom React Hook function react-hooks/rules-of-hooks
代码:
export default function config({ me, setMePut }) {
co
刚把react从v16更新到v17,得到了错误,编译失败。 Line 37:9: React Hook "Api.useAuth" is called conditionally. React Hooks must be called in the exact same order in every component render react-hooks/rules-of-hooks
Line 47:9: React Hook &
这是第一次海报。总的来说,我是个新手& JS,我一直在NextJS工作。有趣的是,我的项目在运行next dev时运行得很好,但是当我使用next build时却失败了。
我得到以下错误:
Error: React Hook "useFunction" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function. react-hooks/rules-of-hooks
关于useFu
当单击表单中的按钮时,我试图从类组件导航到另一个组件,但我在使用useNavigate时遇到了问题,因为t's说它只在函数中工作,所以我尝试了下面的代码
import React from 'react';
import "./login.css"
import NavBar from './navbar';
import { useNavigate } from 'react-router-dom';
class Login extends React.Component {
state ={
username