我正在处理一个基于对象键管理字符串数组的函数。假设它看起来是这样的:
import React, { useState, useEffect } from "react";
import FieldContext from "../contexts/FieldContext";
import io from "socket.io-client";
const [socket, setSocket] = useState(null);
// the `data` array gets changed every second due to a W
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
我在使用usestate()钩子进行状态操作后遇到问题。
无法编译错误:
./src/App.js
Line 6:43: React Hook "useState" is called in function "app" which is neither a React function component or a custom React Hook function react-hooks/rules-of-hooks
Line 14:39: React Hook "useState" is called in functio
错误:
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 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钩子来表示状态,但是当我使用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
使用功能组件构建我的ui。我的寄存器组件找不到import react, {useState} from 'react',它返回给我这个错误。 Failed to compile.
./src/pages/Register.js
Line 10:31: React Hook "useState" is called in function "register"
which is neither a React function component or a custom React Hook function
react-hook