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
loadMoreArticles = direction => { | |
const { allArticles, currentCategory } = this.state; | |
const currentCategoryId = this.categories.find( | |
category => category.name === currentCategory | |
).id; | |
const currentCategoryArticles = allArticles.filter( | |
article => article.UserId === currentCategoryId | |
); | |
const pagedArticles = page => { |
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
const getLastPage = () => | |
Math.floor(currentCategoryArticles.length / this.articlesPerPage); |
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
const pagedArticles = page => { | |
const lastIndex = page * this.articlesPerPage; | |
const firstIndex = lastIndex - this.articlesPerPage; | |
return currentCategoryArticles.slice(firstIndex, lastIndex); | |
}; |
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
loadMoreArticles = direction => { | |
// 상태에 저장되어 있는 allArticles와 currentCategory를 이용해서 | |
// 유저에게 보여 줄 currentCategoryArticles를 가져온다. | |
const { allArticles, currentCategory } = this.state; | |
const currentCategoryId = this.categories.find( | |
category => category.name === currentCategory | |
).id; | |
const currentCategoryArticles = allArticles.filter( | |
article => article.UserId === currentCategoryId |
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
render() { | |
const { currentArticles, currentCategory } = this.state; | |
return ( | |
<div className="App"> | |
<Tabs | |
categories={this.categories} | |
currentCategory={currentCategory} | |
changeCurrentCategory={this.changeCurrentCategory} | |
/> |
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
render() { | |
const { currentArticles, currentCategory } = this.state; | |
return ( | |
<div className="App"> | |
<Tabs | |
categories={this.categories} | |
currentCategory={currentCategory} | |
changeCurrentCategory={this.changeCurrentCategory} | |
/> |
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
const Articles = props => { | |
const { articles } = props; | |
return ( | |
<div className="list-group"> | |
{articles.map(article => ( | |
<div | |
className="list-group-item list-group-item-action" | |
key={article.id} | |
> |
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
render() { | |
const { currentArticles, currentCategory } = this.state; | |
return ( | |
<div className="App"> | |
<Tabs | |
categories={this.categories} | |
currentCategory={currentCategory} | |
changeCurrentCategory={this.changeCurrentCategory} | |
/> |
NewerOlder