技术
React(17.0.2)React Native(0.66.4)TypeScript(4.4.4)Storybook @storybook/react-native(5.3.25)@storybook/react-native-server(5.3.23)
我面对的是什么
在我的故事书中,我面临着下面的反应钩子错误。
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the followin
我有一个函数,每次名称状态改变时都会调用该函数。我想把这个更改后的值发送给父组件,但它指出了这个错误:
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原生应用程序使用react-redux,但不知何故出现了这个问题
error: bundling failed: Error: Unable to resolve module `./hooks/useDispatch` from `C:\Users\TF\lesson\node_modules\react-redux\lib\index.js`: The module `./hooks/useDispatch` could not be found from `C:\Users\TF\lesson\node_modules\react-redux\lib\index.j
我是React的新手,我正在尝试将React钩子集成到我遵循的React课程使用的一些项目中。此示例应添加一个输入字段,用于设置页面的背景颜色。当我加载页面时,在1秒后,我得到以下错误 src\App.js
Line 16:43: React Hook "useBackgroundColor" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function react-hook
当我在我的应用程序中输入内容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
我想使用一个useEffect,useState和其他钩子在一个反应网站,而不是与节点建立。如何执行以下操作:
1.How can i use a functional component when adding React to a Website?
2. How can i use hooks in functional component when adding React to a Website?
我不想使用这里引用的基于类的组件
因此,在更新我的应用程序以作出反应之前,我没有这个错误。我跟踪这个来进行升级。这就是我要做的。
我创建了一个自定义钩子来实现Yup并设置自定义消息、使用上下文和其他自定义钩子:
import * as Yup from 'yup';
import { useAppContext } from '../context/AppContext';
import { Locale } from '../utils/locale';
import useLabel from './useLabel';
我有一个react项目,它在文件中定义了一个Signup元素。代码是
import React, { Component } from 'react';
import Button from 'react-bootstrap/Button';
import Form from 'react-bootstrap/Form';
import { useNavigate } from 'react-router-dom';
import postData from './APIREQ';
class Signup ex