我是react-redux的新手。我有这个代码,我正在使用react,redux和TypeScript。在这段使用基于类的组件的代码中,我想使用dispatch来调用动作来增加counter的值,但这给了我以下错误。
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 Re
有一个点击的事件处理程序,当它触发时,我想使用选择器从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-Dom必须是同一版本吗?
我们应用程序中的示例:
React v 15.0.2、React-Dom v 15.3.1
直到最近,我们的应用程序一直运行得很好,我们收到了一个奇怪的错误。
Type Error: Cannot read property 'getNativeNode' of null (ReactReconciler)
这是我几个月来第一次使用react,也是有史以来第一次使用钩子。到目前为止,我很喜欢它,但我遇到了一个问题,这个问题已经阻碍了我几个小时。
我有一个看起来像这样的组件:
import React, { useState } from "react";
import ReactModal from "react-modal";
import { useModal } from "react-modal-hook";
import styled from 'styled-components';
export function Se
在我的react本机应用程序中,我已经开始使用自定义钩子,我创建了一个钩子来检索用户坐标,但是当我的useGeolocation钩子被调用时(在handleUpdateLocation方法中),我总是收到以下警告:
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 Rea
错误:
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的不匹配版本和呈现器(例如renderer ),您可能违反了Hooks的规则,在同一个应用程序*中可能有多个app副本。
import firebase from '../../database/firebase';
import { useDispatch } from 'react-redux';
import * as actions from "../../store/actions&
当我想在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查询使用突变时会出现这个错误。任何形式的反馈都将不胜感激。
注意:我在一个函数(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
我最近在package.json中更改了react和react的版本(我升级了),现在我得到了下面的错误。
×
←→1 of 18 errors on the page
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 (su