React和React-Dom必须是同一版本吗?
我们应用程序中的示例:
React v 15.0.2、React-Dom v 15.3.1
直到最近,我们的应用程序一直运行得很好,我们收到了一个奇怪的错误。
Type Error: Cannot read property 'getNativeNode' of null (ReactReconciler)
下面的代码工作良好,可以成功地显示和隐藏加载图像,因为数据是从数据库获取的。
const App = () => {
const [loading, setLoading] = useState(true);
const base = useBase();
const tab1 = base.getTableByNameIfExists('myfirst_table');
// grab all the records from that table
const records = useRecords(tab1);
useEffect(() => {
在我的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,也是有史以来第一次使用钩子。到目前为止,我很喜欢它,但我遇到了一个问题,这个问题已经阻碍了我几个小时。
我有一个看起来像这样的组件:
import React, { useState } from "react";
import ReactModal from "react-modal";
import { useModal } from "react-modal-hook";
import styled from 'styled-components';
export function Se
我需要在useEffect()中获取一个api。我尝试这样做,它抛出了以下错误:Error: Invalid hook call. Hooks can only be called inside of the body of a function component.
我的代码如下:
-Api,我需要获取:
export const fetchMyApi = async (code) => {
const { data } = await useQuery("data", () =>
clientAPIs.getData(code)
);
ret
我有一个按钮,它应该向API提交一个表单。我收到了一个错误:
Error: Invalid hook call. Hooks can only be called inside of the body of a function...
我的全部代码都在这里:
function SubmitButton(props) {
function SendData(url) {
const [data, setData] = useState([]);
const eta = document.getElementById('eta_value')
async
当我想在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 "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查询使用突变时会出现这个错误。任何形式的反馈都将不胜感激。
注意:我在一个函数(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
您好,我正在尝试创建一个函数,当您单击产品页面上的添加到购物车时调用该函数。此函数位于一个单独的文件中,并被导入到产品页面中,名为onClick。但是,我收到这个错误,指出钩子调用无效。我做错了什么?
import {AuthContext} from '../context/auth'
import gql from 'graphql-tag'
import {Button} from 'semantic-ui-react'
import {useMutation} from '@apollo/react-hooks'
con
我陷入了一个恼人的问题:我从rest服务获取数据(我同时使用了一个类和一个函数),如果我从根应用程序调用该函数,它工作得很好。因此,我尝试从我获得的另一个组件...and中的按钮(onClick)调用我的函数:
“错误:无效的挂钩调用。只能在函数组件的主体内调用挂钩。这可能是由于以下原因之一...”
我浏览了论坛...a,很多人都有类似的问题,但是没有解决方法,你能帮我吗?
import axios from "axios";
import Table from '@material-ui/core/Table';
import TableBody from