import React, { Component } from 'react';
import { View, Text } from 'react-native';
import axios from 'axios';
class AlbumList extends Component {
state = { albums: [] } ;
componentWillMount(){
axios.get('https://rallycoding.herokuapp.com/api/music_albums')
.then(response => this.setState({ albums : response.data }));
}
renderAlbums(){
return this.state.albums.map(album => <Text>{album.title}</Text>)
}
render(){
console.log(this.state);
return (
<View>
{this.renderAlbums()}
</View>
);
}
}
export default AlbumList;
I encountered a "referenceError: Can't find variable: albums" issue that appeared suddenly after working fine. Any idea what might be causing this?