Skip to content

Commit

Permalink
bestsellers cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bonniee committed Jul 31, 2017
1 parent 101f15c commit 1558542
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 29 deletions.
23 changes: 3 additions & 20 deletions src/bestsellers/BookSectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,10 @@ import { StyleSheet, Text, View, Image, SectionList } from "react-native";
import BookItem from "./BookItem";
import NYT from "./NYT";

const mockBooks = [
{
rank: 1,
title: "GATHERING PREY",
author: "John Sandford",
book_image: "http://du.ec2.nytimes.com.s3.amazonaws.com/prd/books/9780399168796.jpg"
},
{
rank: 2,
title: "MEMORY MAN",
author: "David Baldacci",
book_image: "http://du.ec2.nytimes.com.s3.amazonaws.com/prd/books/9781455586387.jpg"
}
];

class BookList extends Component {
constructor(props) {
super(props);
this.state = { data: [] };
this.state = { sections: [] };
}

componentDidMount() {
Expand All @@ -50,10 +35,8 @@ class BookList extends Component {
console.error("Unexpected results");
}

console.info(results);

this.setState({
data: [
sections: [
{
title: "Hardcover Fiction",
data: this._addKeysToBooks(results[0])
Expand Down Expand Up @@ -89,7 +72,7 @@ class BookList extends Component {
return (
<View style={styles.container}>
<SectionList
sections={this.state.data}
sections={this.state.sections}
renderItem={this._renderItem}
renderSectionHeader={this._renderHeader}
/>
Expand Down
10 changes: 1 addition & 9 deletions src/bestsellers/MockBookList.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ const mockBooks = [
class BookList extends Component {
constructor(props) {
super(props);
this.state = { data: [] };
}

componentDidMount() {
this._refreshData();
this.state = { data: this._addKeysToBooks(mockBooks) };
}

_renderItem = ({ item }) => {
Expand All @@ -48,10 +44,6 @@ class BookList extends Component {
});
};

_refreshData = () => {
this.setState({ data: this._addKeysToBooks(mockBooks) });
};

render() {
return <FlatList data={this.state.data} renderItem={this._renderItem} />;
}
Expand Down

0 comments on commit 1558542

Please sign in to comment.