Skip to content

Instantly share code, notes, and snippets.

@gHashTag
Created April 16, 2017 05:39
Show Gist options
  • Save gHashTag/2e5a3860f876c3eb109bb631fcab7e23 to your computer and use it in GitHub Desktop.
Save gHashTag/2e5a3860f876c3eb109bb631fcab7e23 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react'
import {
StyleSheet,
Text,
View
} from 'react-native'
module.exports = React.createClass({
getInitialState() {
return ({
task: ['Take out the trash', 'Get groceries', 'Practice piano']
})
},
renderList(tasks) {
// return individual Views or rows based on the argued tasks
return (
tasks.map((task, index) => {
return (
<View key={task} style={styles.task}>
<Text>
{task}
</Text>
</View>
)
})
)
},
render(){
return(
<View style={styles.container}>
<Text>To-Do Master
</Text>
{this.renderList(this.state.tasks)}
</View>
)
}
})
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment