Skip to content

HT7.1 #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/components/routes/articles.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import React from 'react'
import { connect } from 'react-redux'
import { Route } from 'react-router-dom'
import ArticleList from '../article-list'
import Article from '../article'
import { articlesLoadedSelector } from '../../selectors/index'

function ArticlesRoute() {
function ArticlesRoute({ loadedArticles }) {
return (
<div>
<ArticleList />
<Route path="/articles/:id" children={getArticle} />
{loadedArticles && <Route path="/articles/:id" children={getArticle} />}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тогда ты начнешь ее загружать только после того, как загрузишь список, а можно паралельно

</div>
)
}
Expand All @@ -17,4 +19,10 @@ const getArticle = ({ match }) =>

ArticlesRoute.propTypes = {}

export default ArticlesRoute
function mapStateToProps(state) {
return {
loadedArticles: articlesLoadedSelector(state)
}
}

export default connect(mapStateToProps)(ArticlesRoute)