ReactNative警告:CameraRoll.getPhotos(tag, success, error) is deprecated...
来源:互联网 发布:可爱彩虹图片 知乎 编辑:程序博客网 时间:2024/06/05 17:24
本人只粗略了解标签语言,至于html5,js,css啥的完全外行。我认为ReactNative是移动App开发的趋势,作为一个iOS开发工程师,深知原生开发的局限性,从今天起,像个孩子一样学习RN。使用教材《React Native入门与实践》
解决完上篇问题ReactNative报错:undefined is not an object(evaluating ‘RCTCameraRollManager.getPhotos’)
运行模拟器,发现下面弹了两个警告
CameraRoll.getPhotos(tag, success, error) is deprecated.Use the returned Promise instead CameraRoll.saveImageWithTag(tag, success, error) is deprecated.Use the returned Promise instead
我看了下自己ReactNative版本为0.23,而教材大概是0.1x,去官方中文网站查看文档,发现接口已经变更,getPhotos及saveImageWithTag只接受一个参数,官方示例说会返回一个Promise。我一脸懵逼,这结构该怎么写,示例很明显残缺不全,经过各种探索,得出结果:
原书写方式(0.1x):
CameraRoll.getPhotos(fetchParams,function(data){ console.log(data); var edges = data.edges; var photos = []; for (var i in edges) { photos.push(edges[i].node.image.uri); } _that.setState({ photos:photos }); },function(){ alert('获取照片失败'); });
新书写方式(0.23)
CameraRoll.getPhotos(fetchParams).done(function(data){ console.log(data); var edges = data.edges; var photos = []; for (var i in edges) { photos.push(edges[i].node.image.uri); } _that.setState({ photos:photos }); },function(err){ alert('获取照片失败'); });
saveImageWithTag方法同理,不再敖述
1 0
- ReactNative警告:CameraRoll.getPhotos(tag, success, error) is deprecated...
- ReactNative报错:undefined is not an object(evaluating 'RCTCameraRollManager.getPhotos')
- is deprecated编译警告warning处理
- UITextInputMode currentInputMode is deprecated. 警告的解决
- Swift: 消除警告-kCFStreamNetworkServiceTypeVoIp is deprecated.........
- FFMPEG deprecated 属性与is deprecated [-Wdeprecated-declarations] 警告
- Function ereg() is deprecated Error
- ActionContextCleanUp <<< is deprecated! Please use the new filters警告
- struts2 控制台警告信息 FilterDispatcher <<< is deprecated! 提示 FilterDispatcher 过时
- Hadoop启动时出现Warning: $HADOOP_HOME is deprecated.警告
- (前端)警告:Synchronous XMLHttpRequest on the main thread is deprecated
- ReactNative.createElement is deprecated. Use React.createElement from the "react" package instead.
- 解决警告:View.propTypes has been deprecated and will be removed in a future version of ReactNative
- “NDK integration is deprecated in the current plugin” Error
- “NDK integration is deprecated in the current plugin” Error
- Error: NDK integration is deprecated in the current plugin
- Error: NDK integration is deprecated in the current plugin
- Error: NDK integration is deprecated in the current plugin
- UITextField
- android仿微信聊天界面
- java并发-Semaphore
- 制作动态库 dynamic framework
- IP地址、子网掩码、网络号、主机号、网络地址、主机地址
- ReactNative警告:CameraRoll.getPhotos(tag, success, error) is deprecated...
- 杂记
- Markdown笔记
- hduoj1272(经典并查集判环)
- CentOS中python升级之后yum无法使用的问题
- 【加密】各种加密(打乱)易语言代码的sdk代码
- 晒圈数据库设计
- Java文件上传下载
- Android API Guides---Migrating to WebView in Android 4.4