我有一个 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(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
我有一个名为useIsUserSubscribed的自定义钩子,它检查是否订阅了特定的用户。如果用户被订阅,则返回true,如果用户没有订阅,则返回false .
import { useState, useEffect } from "react";
import { useSelector } from "react-redux";
import { checkSubscription } from "../services";
// this hook checks if the current user is subscribed to
我有一个函数,每次名称状态改变时都会调用该函数。我想把这个更改后的值发送给父组件,但它指出了这个错误:
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
有一个点击的事件处理程序,当它触发时,我想使用选择器从redux中提取特定的数据,其中所有的逻辑都是多对多实现的。我需要将id传递给它,以便接收它的单独数据。根据react的规则,可以在既不是React函数组件也不是自定义React Hook函数的函数中调用钩子。
那么解决我的问题的方法是什么呢?
const handleMediaItemClick = (media: any): void => {
// For example i check media type and use this selector to pull redux data by id
const
当我使用react("react-redux": "^7.2.2")从服务器获取数据后进行反路径操作,如下所示:
import axios from 'axios';
import store from "../store";
import { getArticle } from "../action/ArticleAction";
import { useDispatch } from 'react-redux';
export function requestWithAction(confi
我使用向用户显示表单,一次显示一个面板。有一个“重置”按钮,用于重置用户可能按下的任何按钮的影响。按钮在面板内部。如何以编程方式折叠任何打开的面板?有针对AccordionItem的dangerouslySetExpanded选项,但我没有看到任何使用此选项的实际示例或该选项的完整文档(这就是该的位置)。我是否必须在这里为每个项的展开-折叠状态使用状态变量才能以编程方式对其进行操作?以下是我现在拥有的代码的简化版本:
import React from 'react';
import ToggleButton from "react-bootstrap/ToggleBu
在呈现我的React组件时,我从ESlint那里得到了一个关于我是如何使用钩子的错误。
React Hook "useReactiveVar" is called conditionally. React Hooks must be called in the exact same order in every component render
下面是我的密码。我怎么解决这个问题?
import { useEffect } from 'react';
import { useApolloClient, useReactiveVar } from '@a
我有一个组件,它使用另一个组件作为呈现器。但是,React不允许我在呈现器组件中使用钩子,因为它会引发以下错误:
Error: Invalid hook call. Hooks can only be called inside of the body of a function component.
下面是显示组件中的一个示例,它是一个错误边界
class DisplayComponent extends Component {
// ...
render() {
const { rendererComponent } = this.props;
return re
我是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
我基于变量加载呈现两个Chakra UI组件:
{loading ? (<Spinner>) : (<Text color={useColorModeValue('gray.800', 'gray.400')>Hi</Text) }
但是IDE警告我这一点:ESLint: React Hook "useColorModeValue" is called conditionally. React Hooks must be called in the exact same order in every componen