[React Native] Create a component using ScrollView
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的更多相关文章
- React Native 中的component 的生命周期
React Native中的component跟Android中的activity,fragment等一样,存在生命周期,下面先给出component的生命周期图 getDefaultProps ob ...
- [RN] React Native 中使用 stickyHeaderIndices 实现 ScrollView 的吸顶效果
React Native中,ScrollView组件可以使用 stickyHeaderIndices 轻松实现 sticky 效果. 例如下面代码中: <ScrollView showsVert ...
- React Native 获取组件(Component)在屏幕上的位置
年后主客户端的需求以及老的业务迁移RN,现在疯狂的在学RN.在迁移需求的时候遇到需要获取组件在屏幕上的绝对位置.页面如下: 就需要展开的时候获取sectionHeader(默认排序)在屏幕上的具体位置 ...
- React Native Expected a component class,got [object Object]解决
报错原因: 组件大小写错误. 解决方式: 修改组件名称即可. 这篇博客介绍了大部分RN的错误原因和解决方法: http://blog.csdn.net/chichengjunma/article/de ...
- React Native 控制一个component的显示隐藏
// 首先在constructor里: this.state = { visible: false } // 然后在点击事件设置: this.setState({ visible: t ...
- [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 ...
- React Native 中 component 生命周期
React Native 中 component 生命周期 转自 csdn 子墨博客 http://blog.csdn.net/ElinaVampire/article/details/518136 ...
- [转] 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 ...
- React Native之 ScrollView介绍和使用
前言 学习本系列内容需要具备一定 HTML 开发基础,没有基础的朋友可以先转至 HTML快速入门(一) 学习 本人接触 React Native 时间并不是特别长,所以对其中的内容和性质了解可能会有所 ...
随机推荐
- bzoj3142
百度空间发公式太累,给个比较详细的解题链接吧http://www.cnblogs.com/jianglangcaijin/archive/2013/08/13/3254314.html注意M(k-1) ...
- Css3 Media Queries移动页面的样式和图片的适配问题(转)
CSS3 Media Queries 摘自:http://www.w3cplus.com/content/css3-media-queries Media Queries直译过来就是“媒体查询”,在我 ...
- 8.21 usaco
summary:6 bzoj1692://后缀数组就行了O(nlogn)c[30]会RE...注意!!! #include<cstdio> #include<cstring> ...
- Bootstrap 源码解析(转)
1.Bootstrap的作用域 2.Bootstrap的类定义 3.Bootstrap的插件定义 4.Bootstrap的事件代理 5.Bootstrap的对象数据缓存 6.Bootstrap的防冲突 ...
- Azure HDInsight与Hadoop周边系统集成
Sunwei 9 Dec 2014 1:54 AM 传统的Hadoop系统提供给用户2个非常优秀的框架,MR计算框架和HDFS存储框架,尽管MR已经显得有些老迈而缓慢,但是HDFS还是很多应用系统的 ...
- 陈正冲老师对于c语言野指针的解释
那到底什么是野指针呢?怎么去理解这个“野”呢?我们先看别的两个关于“野”的词: 野孩子:没人要,没人管的孩子:行为动作不守规矩,调皮捣蛋的孩子.野狗:没有主人的狗,没有链子锁着的狗,喜欢四处咬人. 对 ...
- 问题与解答 [Questions & Answers]
您可以通过发表评论的方式提问题, 我如果有时间就会思考, 并给出答案的链接. 如果您学过Latex, 发表评论的时候请直接输入Latex公式; 反之, 请直接上传图片 (扫描.拍照.mathtype ...
- java jvm学习笔记四(安全管理器)
欢迎装载请说明出处:http://blog.csdn.net/yfqnihao 前面已经简述了java的安全模型的两个组成部分(类装载器,class文件校验器),接下来学习的是java安全模型的另外一 ...
- socket基本操作
我们深谙信息交流的价值,那网络中进程之间如何通信,如我们每天打开浏览器浏览网页时,浏览器的进程怎么与web服务器通信的?当你用QQ聊天时,QQ进程怎么与服务器或你好友所在的QQ进程通信?这些都得靠so ...
- Zabbix探索:资产信息的妙用
前一阵子还在考虑CMDB的问题,因此Zabbix中的Inventory,也就是所谓的资产信息,遭到了我的不少鄙视. 这几天在研究告警通知对应责任人的问题,突然想起Zabbix的资产信息中应该有这么一栏 ...