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. poj3468(线段树 边覆盖)

    #include<cstdio> int lb,rb,data; long long sum[5000000],extra[5000000]; void add(int l,int r,i ...

  2. Mint Linuxubuntu 字体配置文件

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

  3. 【转】iOS手势识别的详细使用(拖动,缩放,旋转,点击,手势依赖,自定义手势) -- 不错不错

    原文网址:http://blog.csdn.net/totogo2010/article/details/8615940 1.UIGestureRecognizer介绍 手势识别在iOS上非常重要,手 ...

  4. android中Invalidate和postInvalidate的区别

    Android中实现view的更新有两组方法,一组是invalidate,另一组是postInvalidate,其中前者是在UI线程自身中使用,而后者在非UI线程中使用. Android提供了Inva ...

  5. chmod命令

    chmod命令用于改变linux系统文件或目录的访问权限.用它控制文件或目录的访问权限.该命令有两种用法.一种是包含字母和操作符表达式的文字设定法:另一种是包含数字的数字设定法. Linux系统中的每 ...

  6. Ildasm.exe(MSIL 反汇编程序)

    MSIL 反汇编程序是 MSIL 汇编程序 (Ilasm.exe) 的伙伴工具. Ildasm.exe 采用包含 Microsoft 中间语言 (MSIL) 代码的可迁移可执行 (PE) 文件,并创建 ...

  7. POJ1177 Picture 线段树+离散化+扫描线

    求最终的覆盖图形周长,写这种代码应该短而精确,差的比较远 /* Problem: 1177 User: 96655 Memory: 348K Time: 32MS Language: C++ Resu ...

  8. 【C/C++运行时库】 /MT /MTd /MD /MDd对C/C++运行库的影响

    欢迎转载 转载请注明出处:http://www.cnblogs.com/cuish/p/3146937.html 测试VS中[项目属性]-[C/C++]-[代码生成]选项中的[运行库]- [ /MT, ...

  9. 【译】 AWK教程指南 附录A-Patterns

    awk 通过判断 Pattern 的值来决定是否执行其后所对应的Actions.这里列出几种常见的Pattern: A.1 BEGIN BEGIN 为 awk 的保留字,是一种特殊的 Pattern. ...

  10. 你知道C/S和B/S两种架构有什么区别吗?

    C/S和B/S,是再普通不过的两种软件架构方式,都可以进行同样的业务处理,甚至也可以用相同的方式实现共同的逻辑.既然如此,为何还要区分彼此呢?那我们就来看看二者的区别和联系. 一.C/S 架构     ...