Nav to Repos component from Dashboard.js:
Gotorepos () { Api.getrepos(this. Props.userInfo.login) . Then (res)= { this. Props.navigator.push ({ 'Repos' , Component:repos, passprops: { this. Props.userinfo, repos:res } }); }) }
Repos:
Import React, {Component} from ' React '; import {View, StyleSheet, Text, ScrollView, touchablehighlight} from' React-native '; import Badge from'./badge '; import Divdir from'./helpers/divdir ';varStyles =stylesheet.create ({container: {flex:1,}, Rowcontainer: {flexdirection:' Column ', Flex:1, padding:10}, Name: {color:' #48BBEC ', FontSize:18, Paddingbottom:5}, Stars: {color:' #48BBEC ', FontSize:14, Paddingbottom:5}, Description: {fontSize:14, Paddingbottom:5}}); class Repos extends react.component{openpage (URL) {console.log (' The URL is ', URL); } render () {varList = This. Props.repos.map (repo, index) ={Const DESC= Repo.description? <text style={styles.description}> {repo.description} </Text>: <view/>; return ( <view key={index}> <view style={styles.rowcontainer}> <touchablehighlight onpress={ This. Openpage.bind ( This, Repo.html_url)} Underlaycolor= ' Transparent ' > <text style={styles.name}>{repo.name}</text> </TouchableHighlight> <text style={styles.stars}> stars: {repo.stargazers_count} &L T;/text>e {desc}<Divdir></Divdir> </View> </View> ) }); return ( <scrollview style={styles.container}> <badge userinfo={ This. Props.userinfo}/>{List}</ScrollView> ) }}; Repos.proptypes={userInfo:React.PropTypes.object.isRequired, repos:react.proptypes.object.isrequired};module.exports= Repos;
[React Native] Build a Github repositories component