Created
May 1, 2017 11:57
-
-
Save alexjosesilva/55d3e048f53221d33e89f2fbf396327b to your computer and use it in GitHub Desktop.
#App4: Listando catalog de Produtos:ListaItens.js
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
/* | |
Usado #App4: Listando catalog de Produto | |
Alex | |
*/ | |
import React, { Component } from 'react'; | |
import { | |
Text | |
} from 'react-native'; | |
export default class Itens extends Component { | |
render() { | |
return ( | |
<Text>Detalhes do item...</Text> | |
); | |
} | |
} |
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
/* | |
* Usado #App4: Listando catalog de Produtos | |
*/ | |
import React, { Component } from 'react'; | |
import { | |
View, | |
Text | |
} from 'react-native'; | |
import axios from 'axios'; | |
import Itens from './Itens'; | |
export default class ListaItens extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { listaItens: [] }; | |
} | |
componentWillMount() { | |
//requisção HTTP | |
axios.get('http://faus.com.br/recursos/c/dmairr/api/itens.html') | |
.then(response => { this.setState({ listaItens: response.data }); }) | |
.catch(() => { console.log('Erro ao recuperar os dados'); }); | |
} | |
render() { | |
return ( | |
<View> | |
{ this.state.listaItens.map(item => (<Text key={item.titulo}>{item.titulo}</Text>))} | |
</View> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment