Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, {Component} from 'react';
- import {View, Text, FlatList} from 'react-native';
- class SongNameList extends Component {
- constructor() {
- super();
- this.state = {
- dataSource: []
- }
- }
- renderItem = ({item}) => {
- return (<View>
- <Text>
- {item.name}
- </Text>
- </View>)
- }
- componentDidMount() {
- const url = 'https://api.JSON.com/api/?option=ejemplo'
- fetch(url).then((response) => response.json()).then((responseJson) => {
- this.setState({dataSource: responseJson.VXM_POP_ESPANOL_ENERGIZANTE})
- });
- }
- render() {
- return (<View>
- <FlatList
- data = {this.state.dataSource}
- renderItem = {this.renderItem}
- keyExtractor = {(item, index) => index}
- ItemSeparatorComponent = {this.renderSeparator} />
- </View>
- );
- }
- }
- componentDidMount() {
- const url = 'https://api.JSON.com/api/?option=ejemplo'
- fetch(url).then((response) => response.json()).then((responseJson) => {
- let popEnergizante = responseJson.VXM_POP_ESPANOL_ENERGIZANTE;
- let popEspanol = popEnergizante.concat(responseJson.VXM_POP_ESPANOL_FESTIVO);
- this.setState({dataSource: popEspanol})
- });
- }
Add Comment
Please, Sign In to add comment