Skip to content
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

Total number of pages via 'maxPageSelector' is incorrect #788

Closed
MichaelDeBoey opened this issue Jan 12, 2018 · 3 comments
Closed

Total number of pages via 'maxPageSelector' is incorrect #788

MichaelDeBoey opened this issue Jan 12, 2018 · 3 comments

Comments

@MichaelDeBoey
Copy link

Griddle version

1.11.1

Problem

When I'm implementing the Navigation myself, by copying the original and just adding

<div>of {maxPages}</div>

The shown maxPages will always result in 1, like you can see in the CodeSandbox instead of the 10 that's shown in the dropdown

The maxPageSelector that I use is the same that gets called in PageDropdownContainer, so am I still doing something wrong? 😕

CC: @dahlbyk

@dahlbyk
Copy link
Contributor

dahlbyk commented Jan 12, 2018

You're using the default maxPageSelector, which requires that you manage pageProperties.recordCount yourself. You want to use LocalPlugin.selectors.maxPageSelector` instead: https://codesandbox.io/s/zl0r5jz7nl.

It would be more correct to get selectors from React context (example), but we don't consistently follow that pattern even within the default components.

For the record, the recommended Griddle pattern for what you're doing would put the connect inside PaginationContainer and let Pagination focus only on rendering from props.

@MichaelDeBoey
Copy link
Author

Doh! 😓
Totally missed out on the LocalPlugin 😓
Thanks for bringing that up! 🙂

We don't want to use the React context since that's not recommended, but thanks for the tip 😉

@dahlbyk
Copy link
Contributor

dahlbyk commented Jan 15, 2018

We don't want to use the React context since that's not recommended, but thanks for the tip

To be clear, Griddle uses context extensively for making configuration (e.g. composed components from plugins/props) available to child components (Parent-Child Coupling). You probably shouldn't use it for your own app's infrastructure, but it's often the correct way to customize Griddle (see #740, #743).

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

No branches or pull requests

2 participants