我正在遵循一个教程,使用ThirdWeb和react.js构建一个NFT市场。当我试图将ThirdWeb连接到Rinkebey测试网络时,我在_app.tsx文件中得到了以下错误:
Type '{ children: ReactNode; supportedChainIds: number[]; connectors: { injected: {}; }; }' is not
assignable to type 'IntrinsicAttributes & ThirdwebWeb3ProviderProps'.
Property 'children' does not exist on type 'IntrinsicAttributes & ThirdwebWeb3ProviderProps这是我的_app.tsx文件
import '../styles/globals.css'
import { ThirdwebWeb3Provider } from '@3rdweb/hooks'
/**
* The chain ID 4 represents the Rinkeby network
* The `injected` connector is a web3 connection method used by Metamask
*/
const supportedChainIds = [4]
const connectors = {
injected: {},
}
type Props = {
children?: React.ReactNode
};
function MyApp(props: Props) {
return (
<ThirdwebWeb3Provider
supportedChainIds={supportedChainIds}
connectors={connectors}
>
{props.children}
</ThirdwebWeb3Provider>
)
}
export default MyApp我试过想办法解决问题,但无法找到任何解决办法。
请有人帮我解决这个错误。
发布于 2022-09-26 19:34:10
你可以:
const MyApp: React.FC<PropsWithChildren<Props>>(props) {
return (
<ThirdwebWeb3Provider
supportedChainIds={supportedChainIds}
connectors={connectors}
>
{props.children}
</ThirdwebWeb3Provider>
)
}发布于 2022-08-03 19:29:28
React 18移除默认的道具“子”。似乎库作者没有手动更新他们的道具界面来添加“子”。您可以尝试将本地版本的react降级为16.X.X或17.X.X,这将解决问题。
发布于 2022-08-18 00:41:32
您使用的是第三个‘re包的不推荐版本,最新更新的包是@thirdweb-dev/react,在该软件包中不会发生此错误。
https://stackoverflow.com/questions/73180068
复制相似问题