Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react'
- import { View, Text } from 'react-native'
- import axios from 'axios'
- class List extends Component {
- state = {
- username: this.props.navigation.getParam('name'),
- reposList: []
- }
- constructor(props){
- super(props)
- }
- componentDidMount() {
- axios.get(`https://api.github.com/users/${this.state.username}/repos`)
- .then(response => {
- alert(response)
- this.setState({reposList: response})
- })
- .catch(error => alert(error))
- }
- mountList() {
- return this.state.reposList.map(item, index => {
- return (
- <View>
- <Text>{item.name}</Text>
- <Text>{item.full_name}</Text>
- </View>
- )
- })
- }
- render() {
- return (
- <View>
- <Text>{this.state.reposList}</Text>
- </View>
- )
- }
- }
- List.navigationOptions = {
- title: 'List'
- }
- export default List
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement