Skip to content

Instantly share code, notes, and snippets.

@aitemr
Created April 10, 2018 23:06
Show Gist options
  • Save aitemr/3f1995c3b1aaaa80fd1a10d896731c6c to your computer and use it in GitHub Desktop.
Save aitemr/3f1995c3b1aaaa80fd1a10d896731c6c to your computer and use it in GitHub Desktop.
import React, { Component } from 'react'
import {
AppRegistry,
StyleSheet,
Text,
View,
FlatList,
Image,
ScrollView
} from 'react-native'
class App extends Component {
state = {
images: [],
isLoading: false,
}
componentDidMount() {
this.executeQuery()
}
executeQuery = () => {
this.setState({ isLoading: true });
fetch('https://www.instagram.com/today_kz/?__a=1')
.then(response => response.json())
.then(json => this.handleResponse(json))
.catch(() =>
this.setState({
isLoading: false,
})
);
};
handleResponse = response => {
const images = response.graphql.user.edge_owner_to_timeline_media.edges.map(
edge => edge.node
);
this.setState({ isLoading: false, images });
};
renderItems = () => {
return this.state.images.map((item) => {
return (
<Image style={{ height: 100, width: 200 }} source={{ uri: item.display_url }}/>
)
})
}
keyExtractor = item => item;
render() {
return (
<ScrollView>
{this.renderItems()}
</ScrollView>
);
}
}
const styles = StyleSheet.create({
})
// export default App;
AppRegistry.registerComponent('App', () => App)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment