[英]How to resolve index.js:9 Uncaught TypeError: Cannot read property 'setWallpaper' of undefined?
Hello All I'm new to react native and started with wallpaper app.大家好,我是本机反应的新手,并开始使用壁纸应用程序。 I'm using react-native-wallpaper-manager to built an App and I'm getting following error:
我正在使用react-native-wallpaper-manager构建一个应用程序,但出现以下错误:
index.js:9 Uncaught TypeError: Cannot read property 'setWallpaper' of undefined
index.js:9 未捕获的类型错误:无法读取未定义的属性“setWallpaper”
index.js索引.js
var NativeModules = require('react-native');
var Image = require('react-native');
module.exports = {
setWallpaper: (source,callback = (res)=>{
console.log(res);
}) =>{
NativeModules.WallPaperManager.setWallpaper(Image.resolveAssetSource(source),callback);
}
} ;
App.js应用程序.js
WallPaperManager.setWallpaper({uri: 'img_link', screen: 'both/home/lockscreen'}, (res)=> console.log(res));
Please help me to resolve this error.请帮我解决这个错误。
I'm had the same issue.我有同样的问题。 I have tried these libraries as well , all gettings the same error
我也试过这些库,都得到同样的错误
https://www.npmjs.com/package/react-native-manage-wallpaper https://www.npmjs.com/package/react-native-manage-wallpaper
https://www.npmjs.com/package/react-native-wallpaper-enhanced https://www.npmjs.com/package/react-native-wallpaper-enhanced
Try this one instead https://www.npmjs.com/package/react-native-manage-wallpaper/v/1.1.2试试这个https://www.npmjs.com/package/react-native-manage-wallpaper/v/1.1.2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.