从@react本机异步存储/异步存储导入异步存储时出现问题



获取错误信息

Type 'AsyncStorageStatic' is missing the following properties from type 'IAsyncStorage<string, any>': store, size, getStorets(2739

我已经按照文档进行了安装,但是仍然有错误。

您可以在这个文件中找到您需要的类型:

~/node_modules/keyvaluestorage/dist/cjs/react-native/types.d.ts

内容为:

export declare namespace AsyncStorageTypes {
type Entry<K = string, V = any> = [K, V | null];
type Entries<K = string, V = any> = Array<Entry<K, V>>;
type ErrBack<V = any> = (err: Error | null, val?: V | null) => {};
type ArrErrBack<V = any> = (err: Array<Error> | null, val?: V) => {};
}
export declare abstract class IAsyncStorage<K = string, V = any> {
abstract store: Map<K, V | null>;
abstract size(): number;
abstract getStore(): Map<K, V | null>;
abstract getItem(k: K, cb?: AsyncStorageTypes.ErrBack<V>): Promise<V | null>;
abstract setItem(k: K, v: V, cb?: AsyncStorageTypes.ErrBack<V>): Promise<void>;
abstract removeItem(k: K, cb?: AsyncStorageTypes.ErrBack<V>): Promise<void>;
abstract clear(cb?: AsyncStorageTypes.ErrBack<V>): Promise<void>;
abstract getAllKeys(cb?: AsyncStorageTypes.ErrBack<Array<K>>): Promise<Array<K>>;
abstract multiGet(keys: Array<K>, cb?: AsyncStorageTypes.ErrBack<AsyncStorageTypes.Entries<K, V>>): Promise<AsyncStorageTypes.Entries<K, V>>;
abstract multiSet(entries: AsyncStorageTypes.Entries<K, V>, cb?: AsyncStorageTypes.ErrBack<V>): Promise<void>;
abstract multiRemove(keys: Array<K>, cb?: AsyncStorageTypes.ErrBack<V>): Promise<void>;
abstract mergeItem(key: string, value: string, cb?: AsyncStorageTypes.ErrBack<string>): Promise<void>;
abstract multiMerge(entries: AsyncStorageTypes.Entries<string, string>, cb?: AsyncStorageTypes.ArrErrBack<string>): Promise<void>;
abstract flushGetRequests(): any;
}

导入或复制到您的代码中,然后执行如下操作:

<WalletConnectProvider
storageOptions={{
asyncStorage: AsyncStorageStatic as unknown as IAsyncStorage,
}}
>
<App/>
</WalletConnectProvider>

有时你需要重新启动你的android模拟器或停止它并重新开始,如果它没有找到类型或模块安装后。

最新更新