Skip to content

Instantly share code, notes, and snippets.

@noximus
Forked from thecookieorg/Home.js
Last active November 7, 2018 02:08
Show Gist options
  • Save noximus/fb7a5e07d1100fa287a0d3ad1e0f06eb to your computer and use it in GitHub Desktop.
Save noximus/fb7a5e07d1100fa287a0d3ad1e0f06eb to your computer and use it in GitHub Desktop.
snippet I grabbed from somewhere
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