我有一个由 create-react-app 和 React 组件库组成的 React 应用程序。我正在尝试将组件库链接到应用程序以在本地测试组件。当我尝试使用库中的组件时,出现错误:
\nUncaught 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:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nRun Code Online (Sandbox Code Playgroud)\n我在互联网上(主要是这个问题)搜索了这个问题的解决方案,并找到了一些关于链接应用程序的 React 依赖项并在组件库中使用链接的 React 的建议。这似乎对几个人都有效,所以我通过执行以下操作来完成此操作:
\n在应用程序中: …
1>Deck.obj : error LNK2005: "class Card card" (?card@@3VCard@@A) already defined in Card.obj
1>PokerTester.obj : error LNK2005: "class Card card" (?card@@3VCard@@A) already defined in Card.obj
1>PokerTester.obj : error LNK2005: "class Deck deck" (?deck@@3VDeck@@A) already defined in Deck.obj
1>C:\Dev\Poker\Debug\Poker.exe : fatal error LNK1169: one or more multiply defined symbols found
Run Code Online (Sandbox Code Playgroud)
我已经通过谷歌搜索了解到为什么会发生这些错误,但我不知道为什么当我尝试过 #pragma once 和 #ifndef 保护事情时它们仍然发生。
这是我的 Card.h
#pragma once
#ifndef CARD_H
#define CARD_H
#include <iostream>
#include <string>
using namespace std;
class Card
{
public:
Card(int cardSuit = 0, int cardValue = …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用异步查询数据库,ExecuteReaderAsync()但是我收到以下错误:
'System.Data.SqlClient.SqlCommand' does not contain a definition for
'ExecuteReaderAsync' and no extension method 'ExecuteReaderAsync' accepting a first
argument of type 'System.Data.SqlClient.SqlCommand' could be found (are you missing a
using directive or an assembly reference?)
Run Code Online (Sandbox Code Playgroud)
我正在使用VSE 2012 for Windows Desktop并且.NET 4.5已经安装.我正在引用
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Data.dll
Run Code Online (Sandbox Code Playgroud)
我已经读过.NET 4.5只是替换4.0,但每当我尝试在4.5目录中选择System.Data.dll时,它都会引用4.0中的那个.不确定是否重要.