wuyunqiang

Results 67 issues of wuyunqiang

参考如下: [AndroidToRN](https://github.com/wuyunqiang/AndroidToRN)

android

[ react navigation返回到任意页面](http://blog.csdn.net/u014041033/article/details/77880400)

react navigation

import PropTypes from 'prop-types'; static propTypes = { //需要的类型 cx: PropTypes.xxx.isRequired, }; static defaultProps = { cx: 0, //类型默认值 };

PropTypes

在使用listitem的时候发现在Android上右图片默认显示不出来,在iOS运行直接报错 Unrecognized font family 'Material Icons'。 ![androidlistitem.png](http://upload-images.jianshu.io/upload_images/3353755-e3c54fc43384938e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/400) ![ioslistitem.png](http://upload-images.jianshu.io/upload_images/3353755-6047b77b047147b9.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/400) 修复: 打开ListItem源码发现这个 ![code.png](http://upload-images.jianshu.io/upload_images/3353755-bc202576f28321ed.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/400) 所以解决这个很简单只要设置hidechevron=true就可以了。 ![fixcode.png](http://upload-images.jianshu.io/upload_images/3353755-b8a816a09e6e8155.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/400) 或者也可以修改设置默认值 ![default.png](http://upload-images.jianshu.io/upload_images/3353755-77884d6e52a5523e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/400) 修改后效果: ![androidright.png](http://upload-images.jianshu.io/upload_images/3353755-ac4dfbc2c7e16469.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/400) ![iosright.png](http://upload-images.jianshu.io/upload_images/3353755-eb132060902ebcfb.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/400) 版本信息: "react": "16.0.0-alpha.6", "react-native": "0.44.3", "react-native-elements": "^0.14.0", "react-native-vector-icons": "^4.2.0", 相关issue: https://github.com/react-native-training/react-native-elements/issues/503

react-native-elements

这种错误一般是在新加入组件库时遇到,只要重新编译即可。 错误如图: ![androidbuild.png](http://upload-images.jianshu.io/upload_images/3353755-60cf7ef85296ceb9.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/800) 如果出现这个: ![androidbuild2.png](http://upload-images.jianshu.io/upload_images/3353755-62c5a07cc392adf8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/800) 点击: ![androidbuild3.png](http://upload-images.jianshu.io/upload_images/3353755-0e7433779b02a171.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/800) 然后依次点击 ![androidbuild4.png](http://upload-images.jianshu.io/upload_images/3353755-49596650818ae5cf.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/800) 如果遇到什么OK的一律OK 配置完毕就可以了。

android
build

[官方issue](https://github.com/react-community/react-navigation/issues/2829) bug 如图: ![reactnavigationflash](https://user-images.githubusercontent.com/13480948/32043806-59bc7f76-ba6e-11e7-956d-5fb367673e70.gif) 解决办法: 设置TabNavigator中的 ``` animationEnabled: false。 ``` 或者animationEnabled属性和动画一起设置 ``` animationEnabled: true, configureTransition:()=>_configureTransition(), ``` ``` const _configureTransition = () => { return { duration: 100, timing: Animated.spring, };...

react navigation

发现在使用react-native-snap-carousel或者react-native-swiper时都会出现切换白屏的情况 如图: ![whiteScreen.gif](http://upload-images.jianshu.io/upload_images/3353755-2fef371be0ad8d71.gif?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 思路: 这是因为在切换tab是正好执行图片切换,导致图片渲染不出来。 我的想法是监听tab的监听事件,在切换前禁止轮播的循环,再次回到此页面时,重新开始循环,这样就不会出现白屏现象。 步骤: 1:首先在tab时监听点击事件,因为我是自己自定义的tab,所以可以很容易的获取监听。 ``` { DeviceEventEmitter.emit('TabChange', index);//这里在跳转前发送一个消息 然后在轮播页监听事件 jumpToIndex(index); }} style={{width:WIDTH/count,flexDirection:'row', justifyContent:'space-around',}} activeOpacity={1} > {this.props.renderIcon(TabScene)} {this.props.getLabel(TabScene)} ``` 关于自定义react-navigation 的Tab请参考https://github.com/wuyunqiang/ReactNativeUtil/issues/9 2:轮播页代码: 添加监听事件 ``` componentDidMount() { this.listentab...

react-native-snap-carousel
轮播

``` import {Dimensions,PixelRatio,Platform} from 'react-native'; export const deviceWidth = Dimensions.get('window').width; //设备的宽度 export const deviceHeight = Dimensions.get('window').height; //设备的高度 let fontScale = PixelRatio.getFontScale(); //返回字体大小缩放比例 let pixelRatio = PixelRatio.get(); //当前设备的像素密度 const defaultPixel =...

Util

``` /* * 从上至下动画 * */ const forVerticalTop = (sceneProps)=>{ const { layout, position, scene } = sceneProps; const { route } = scene; const index = scene.index; const height...

react navigation

redux的数据是在配置时候传入的,只能使用自己的部分,那么我们获取其他部分的store该如何做呢? 其实redux的数据的传递也是通过context做到的,如果大家不熟悉可以去搜索一下关于context的文章 [context文章](http://www.jianshu.com/p/a2f5a3edbfd4) 学习一下这里只讲方法: 1:直接设置 ``` static contextTypes = { store: PropTypes.object, }; ``` 2: console.log('store getState',this.context.store.getState());//获取全局store

redux