ReactNative github 模拟项目记录

2017-09-20  本文已影响41人  耳_总

创建项目

命令:cd xxxx 目录
react-native init 工程名字
用webstrom打开

知识点记录:

static propTypes = {
        rightBtn: PropTypes.element,
    }
ExceptionsManager.js:63 Navigator is deprecated and has been removed 
from this package. It can now be installed and imported from `react-native-
deprecated-custom-components` instead of `react-native`. Learn about 
alternative navigation solutions at http://facebook.github.io/react-
native/docs/navigation.html
const {navigate} = this.props.navigation;
        return <View style={styls.container}>
            <NavigationBar title={'我的'}/>
            <Text onPress={() => navigate('CustomKey',{name:'自定义标签'})}>自定义标签</Text>
        </View>

还是取值navigator从上一个页面跳转过来的值的时候:

const {params} = this.props.navigation.state;
        return <View style={styls.container}>
            <NavigationBar title={'自定义标签'}/>
            <Text>{params.name}</Text>
        </View>

都必须是这种写法,如果是这种将取不到值的:

return <View style={styls.container}>
            <NavigationBar title={'自定义标签'}/>
            <Text>{this.props.navigation.state.name}</Text>
        </View>

资料

https://github.com/expo/react-native-tab-navigator
npm install react-native-tab-navigator --save
http://blog.csdn.net/jing85432373/article/details/54342756

npm install --save react-navigation

碰到的问题:

我在mac上前一天盖上盖子后,react的服务挂起了,第二天在引用项目的时候回报错:找不到这个模块,但是明明有啊,点进去还是也有代码联想啊!关掉重启就好了。

待研究的——Navigation

上一篇 下一篇

猜你喜欢

热点阅读