Skip to content

HT6 #37

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 3 commits into
base: master
Choose a base branch
from
Open

HT6 #37

wants to merge 3 commits into from

Conversation

motionrus
Copy link

@motionrus motionrus commented Mar 9, 2019

Первый коммит:

  • HT6.1 Реализовал роут для пагинации комментариев(всех: /comments/page)
  • Не загружаются все комменты если были когда-то загружены

Второй коммит:

  • HT6.2 Реализовал пагинацию, загружая по 5 комментов на страницу(/api/comment?limit=5&offset=10)
  • HT6.3 Загружаю каждую страницу только один раз

Ruslan Tyutin added 3 commits March 9, 2019 11:24
* Не загружаются все комменты если были когда-то загружены
…comment?limit=5&offset=10)

HT6.3 Загружаю каждую страницу только один раз
…считывается динамически. Пофиксил загрузкой первой страницы по умолчанию
if (!loading && !pagesLoaded.includes(page) && fetchAll) {
fetchAll(DEFAULT_OFFSET * (page - 1), page)
}
}, [page])
Copy link
Author

Choose a reason for hiding this comment

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

не знаю что это но чувствую что тут должно быть page. Если я правильно понял, это условие, при каких обстоятельствах вызывать useEffect

Copy link
Owner

Choose a reason for hiding this comment

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

Хороший вопрос для разбора в начале урока, задай в слаке

const { loading, fetchAll, page, pagesLoaded } = props
useEffect(() => {
if (!loading && !pagesLoaded.includes(page) && fetchAll) {
fetchAll(DEFAULT_OFFSET * (page - 1), page)
Copy link
Owner

Choose a reason for hiding this comment

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

я бы передавал page, а уже в AC превращал это в offset и limit

if (!loading && !pagesLoaded.includes(page) && fetchAll) {
fetchAll(DEFAULT_OFFSET * (page - 1), page)
}
}, [page])
Copy link
Owner

Choose a reason for hiding this comment

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

Хороший вопрос для разбора в начале урока, задай в слаке

loading: false,
loaded: false,
total: 0,
pagesLoaded: List([])
Copy link
Owner

Choose a reason for hiding this comment

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

Set рекомендовал бы

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants