首页 > 解决方案 > 尝试在 React 中导入导出的接口,但 React 找不到

问题描述

我在同一个目录中有两个文件:CosmWasmContext.js 和 CosmWasmHooks.js。

这是在我的 CosmWasmHooks.js 文件中:

export interface ISigningCosmWasmClientContext {
    ...
}

export const useSigningCosmWasmClient = (): ISigningCosmWasmClientContext => {
    ...
}

我想在我的 CosmWasmContext.js 文件中同时使用接口和函数。我只能导入函数 useSigningCosmWasmClient,但不能导入接口。

这些是我尝试从 CosmWasmHooks 导入的方式:

import { useSigningCosmWasmClient,ISigningCosmWasmClientContext } from './CosmWasmHooks'
import { useSigningCosmWasmClient} from './CosmWasmHooks'
import { ISigningCosmWasmClientContext } from './CosmWasmHooks'
import { useSigningCosmWasmClient} from './CosmWasmHooks'
import ISigningCosmWasmClientContext from './CosmWasmHooks'

useSigningCosmWasmClient我可以毫无问题地导入和使用。唯一的问题是ISigningCosmWasmClientContext界面。

有谁知道为什么我在导入时可能会遇到如此奇怪的问题?我以前从未遇到过这个问题。

标签: javascriptreactjsreact-nativedependencies

解决方案


推荐阅读