-
-
Save noximus/fb7a5e07d1100fa287a0d3ad1e0f06eb to your computer and use it in GitHub Desktop.
snippet I grabbed from somewhere
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { View, Text, TouchableOpacity } from 'react-native'; | |
import axios from 'axios'; | |
class Home extends Component { | |
state = { | |
posts: [] | |
} | |
componentWillMount() { | |
axios.get('https://jsonplaceholder.typicode.com/posts') | |
.then((response) => { | |
console.log(response.data); | |
}).catch((error) => { | |
console.log(error); | |
}) | |
} | |
render() { | |
return ( | |
<View | |
style={{ | |
flex: 1, | |
justifyContent: 'center', | |
alignItems: 'center' | |
}} | |
> | |
<TouchableOpacity | |
onPress={() => this.props.navigation.navigate('Details')} | |
style={{ | |
backgroundColor: 'white', | |
padding: 20, | |
borderRadius: 10 | |
}} | |
> | |
<Text style={{ color: 'black' }}>Go to Details</Text> | |
</TouchableOpacity> | |
</View> | |
); | |
} | |
} | |
export default Home; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment