我有一个本机模块,我想输入它。
这是我的模块界面的示例
export interface BBAudioPlayer {
playSound: (sound: 'click' | 'tada') => Promise<void>;
pause: () => Promise<void>;
}
这就是我使用它的方式:
NativeModules.BBAudioPlayer.playSound('tada');
怎样才能延长NativeModules
添加我的新模块的类型?
// extendNativeModules.d.ts
// import original module declarations
import 'react-native';
export interface BBAudioPlayerInterface {
playSound: (sound: 'click' | 'tada') => Promise<void>;
pause: () => Promise<void>;
}
// and extend them!
declare module 'react-native' {
interface NativeModulesStatic {
BBAudioPlayer: BBAudioPlayerInterface;
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)