To show a list of unchanging data in React Native you can use the scroll view component. In this lesson, we'll map through the data we got back from the Github API, and fill complete ScrollView component for the user profile.

After call goToProfile function in Dashboard:

    goToProfile(){
this.props.navigator.push({
title: 'Profile',
component: Profile,
passProps: {userInfo: this.props.userInfo}
});
}

We create a new component 'Profile.js'

import React, {Component} from 'react';
import {View, StyleSheet, Text, ScrollView} from 'react-native'; import Badge from './Badge'; const styles = StyleSheet.create({
container: {
flex:
},
buttonText: {
fontSize: ,
color: 'white',
alignSelf: 'center'
},
rowContainer: {
padding:
},
rowTitle: {
color: '#48BBEC',
fontSize:
},
rowContent: {
fontSize:
}
}); class Profile extends React.Component{
getRowTitle(userInfo, item){
item = (item === 'public_repos') ? item.replace('_', ' ') : item;
return item[] ? item[].toUpperCase() + item.slice() : item;
}
createList(userInfo, topicArr){
return topicArr.map( (item, index) => {
if(!userInfo[item]){
return <View key={index}></View>
}else{
return (
<View style={styles.rowContainer}>
<Text style={styles.rowTitle}> {this.getRowTitle(userInfo, item)} </Text>
<Text style={styles.rowContent}> {userInfo[item]} </Text>
</View>
);
}
})
}
render(){
const userInfo = this.props.userInfo;
const topicArr = ['company', 'location', 'followers', 'following', 'email', 'bio', 'public_repos']; return (
<ScrollView style={styles.container} >
<Badge userInfo={this.props.userInfo} />
{this.createList(userInfo, topicArr)}
</ScrollView>
);
}
} module.exports = Profile;

												

[React Native] Create a component using ScrollView的更多相关文章

  1. React Native 中的component 的生命周期

    React Native中的component跟Android中的activity,fragment等一样,存在生命周期,下面先给出component的生命周期图 getDefaultProps ob ...

  2. [RN] React Native 中使用 stickyHeaderIndices 实现 ScrollView 的吸顶效果

    React Native中,ScrollView组件可以使用 stickyHeaderIndices 轻松实现 sticky 效果. 例如下面代码中: <ScrollView showsVert ...

  3. React Native 获取组件(Component)在屏幕上的位置

    年后主客户端的需求以及老的业务迁移RN,现在疯狂的在学RN.在迁移需求的时候遇到需要获取组件在屏幕上的绝对位置.页面如下: 就需要展开的时候获取sectionHeader(默认排序)在屏幕上的具体位置 ...

  4. React Native Expected a component class,got [object Object]解决

    报错原因: 组件大小写错误. 解决方式: 修改组件名称即可. 这篇博客介绍了大部分RN的错误原因和解决方法: http://blog.csdn.net/chichengjunma/article/de ...

  5. React Native 控制一个component的显示隐藏

      // 首先在constructor里:   this.state = { visible: false }   // 然后在点击事件设置:   this.setState({ visible: t ...

  6. [React Native] Using the Image component and reusable styles

    Let's take a look at the basics of using React Native's Image component, as well as adding some reus ...

  7. React Native 中 component 生命周期

    React Native 中 component 生命周期 转自 csdn 子墨博客  http://blog.csdn.net/ElinaVampire/article/details/518136 ...

  8. [转] React Native Navigator — Navigating Like A Pro in React Native

    There is a lot you can do with the React Native Navigator. Here, I will try to go over a few example ...

  9. React Native之 ScrollView介绍和使用

    前言 学习本系列内容需要具备一定 HTML 开发基础,没有基础的朋友可以先转至 HTML快速入门(一) 学习 本人接触 React Native 时间并不是特别长,所以对其中的内容和性质了解可能会有所 ...

随机推荐

  1. 几款JS地图插件比较

    因工作需要,最近研究几款关于地图的JS插件,现与大家分享一下. 以下比较只是浅层次的分析一下,并没有实际通过项目检验,所以不足之处还请大家指出. 地图插件对比 插件名  简介 区域支持 扩展性 离线支 ...

  2. Java传参那些事!

    刚刚学习java传参的时候很纠结,也非常的不理解!课本上的“按值传递”和“按址传递”搞的自己是一头雾水,后来写的项目多了,自然就明白了! 现在写传参几乎就是条件反射一般——“秒成”,分享当初自己为此写 ...

  3. Mint Linuxubuntu 字体配置文件

    <?xml version="1.0"?><!DOCTYPE fontconfig SYSTEM "fonts.dtd"><fon ...

  4. 【Java】Java运行cmd命令直接导出.sql文件

    Java中的Runtime.getRuntime().exec(commandStr)可以调用执行cmd命令 package Util; import java.io.File; import jav ...

  5. java vm args

    这个问题主要还是由这个问题 java.lang.OutOfMemoryError: Java heap space 引起的.第一次出现这样的的问题以后,引发了其他的问题.在网上一查可能是JAVA的堆栈 ...

  6. toastr

    $(function(){     //参数设置,若用默认值可以省略以下面代     toastr.options = {         "closeButton": false ...

  7. create Context Menu in Windows Forms application using C# z

    In this article let us see how to create Context Menu in Windows Forms application using C# Introduc ...

  8. 利用文件实现Free Pascal中的简单排序功能

    此程序主要是验证文件功能的读写功能,总结到的东西有:①文件无论是读还是写,都要先建立链接关系才可以进行;②读与写不能同时进行,必须分开操作,这也可以理解,在实际鼠标操作时也是如此的!③读写后必须用cl ...

  9. 转载-KMP算法前缀数组优雅实现

    转自:http://www.cnblogs.com/10jschen/archive/2012/08/21/2648451.html 我们在一个母字符串中查找一个子字符串有很多方法.KMP是一种最常见 ...

  10. [Tommas] 测试场景 VS 测试用例 哪个更好?(转)

    分享一篇网上别人的感悟:      6年前,我在一家中型跨国公司工作的时候,我建议与其浪费时间在准备充分的测试用例,还不如编写描述测试场景的文档.所有的人都对我的建议.投以烦恼的目光.他们的脸上清晰地 ...