-
Notifications
You must be signed in to change notification settings - Fork 626
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
renderOnZeroPageCount missing on type #394
Comments
Hi @equinusocio, The prop is defined in
Which version of the library do you use? |
8.0.0 |
It should be there: Do you have any pointer to know why a prop would not be recognized by TypeScript? |
See
Does this help? Could you create a sample repository in GitHub to reproduce this error? I'm not familiar with TypeScript |
The issue is probably related to https://github.com/DefinitelyTyped/DefinitelyTyped. Because the type definition installed from there doesn't include that property at all:
// Type definitions for react-paginate 7.1
// Project: https://github.com/AdeleD/react-paginate
// Definitions by: Simon Hartcher <https://github.com/deevus>
// Wouter Hardeman <https://github.com/wouterhardeman>
// pegel03 <https://github.com/pegel03>
// Simon Archer <https://github.com/archy-bold>
// Yasunori Ohoka <https://github.com/yasupeke>
// Shingo Sato <https://github.com/sugarshin>
// SPWizard01 <https://github.com/SPWizard01>
// Kevin Rambaud <https://github.com/kevinrambaud>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import * as React from 'react';
export interface ReactPaginateProps {
/**
* The total number of pages.
*/
pageCount: number;
/**
* The range of pages displayed.
*/
pageRangeDisplayed: number;
/**
* The number of pages to display for margins.
*/
marginPagesDisplayed: number;
/**
* Label for the `previous` button.
*/
previousLabel?: React.ReactNode | undefined;
/**
* Label for the `next` button.
*/
nextLabel?: React.ReactNode | undefined;
/**
* Label for ellipsis.
*/
breakLabel?: string | React.ReactNode | undefined;
/**
* The classname on tag `li` of the ellipsis element.
*/
breakClassName?: string | undefined;
/**
* The classname on tag `a` of the ellipsis element.
*/
breakLinkClassName?: string | undefined;
/**
* The method to call when a page is clicked. Exposes the current page object as an argument.
*/
onPageChange?(selectedItem: { selected: number }): void;
/**
* The method to call when an active page is clicked. Exposes the active page object as an argument.
*/
onPageActive?(selectedItem: { selected: number }): void;
/**
* The initial page selected.
*/
initialPage?: number | undefined;
/**
* To override selected page with parent prop.
*/
forcePage?: number | undefined;
/**
* Disable onPageChange callback with initial page. Default: false
*/
disableInitialCallback?: boolean | undefined;
/**
* The classname of the pagination container.
*/
containerClassName?: string | undefined;
/**
* The classname on tag `li` of each page element.
*/
pageClassName?: string | undefined;
/**
* The classname on tag `a` of each page element.
*/
pageLinkClassName?: string | undefined;
/**
* Function to set the text on page links. Defaults to `(page) => page`
*/
pageLabelBuilder?: ((page: number) => string) | undefined;
/**
* The classname for the active page.
*/
activeClassName?: string | undefined;
/**
* The classname for the active link.
*/
activeLinkClassName?: string | undefined;
/**
* The classname on tag `li` of the `previous` button.
*/
previousClassName?: string | undefined;
/**
* The classname on tag `li` of the `next` button.
*/
nextClassName?: string | undefined;
/**
* The classname on tag `a` of the `previous` button.
*/
previousLinkClassName?: string | undefined;
/**
* The classname on tag `a` of the `next` button.
*/
nextLinkClassName?: string | undefined;
/**
* The classname for disabled `previous` and `next` buttons.
*/
disabledClassName?: string | undefined;
/**
* The method is called to generate the href attribute value on tag a of each page element.
*/
hrefBuilder?(pageIndex: number): void;
/**
* @deprecated The extraAriaContext prop is deprecated. You should now use the ariaLabelBuilder instead.
* Extra context to add to the aria-label HTML attribute.
*/
extraAriaContext?: string | undefined;
/**
* The method is called to generate the `aria-label` attribute value on each page link
*/
ariaLabelBuilder?: ((pageIndex: number, selected: boolean) => string) | undefined;
/**
* The event to listen onto before changing the selected page. Default is: "onClick".
*/
eventListener?: string | undefined;
}
declare const ReactPaginate: React.ComponentClass<ReactPaginateProps>;
export default ReactPaginate; |
same issue |
Ok, thanks @equinusocio. So seems like this pulls the types from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-paginate, which is a community repo containing types for many libs. They are type definitions defined and supported here. You can read the CHANGELOG to update and provide the up to date definitions in their index.d.ts and update the test, then submit it as a PR. Do any of you are up to this task? We could also publish a |
If you can just add an Even without using Typescript, puttin that file on the package root dist should solve the issue. You should keep it updated as well |
Done. I can't certify we will always think to update these definitions. (but then a PR will do) Not sure on the parameter for
Can someone with TS test the setup works? npm install --save github:AdeleD/react-paginate |
Can you re-check now @equinusocio?
We don't have to declare this file anywhere? (like in |
Nope, Typescript look for an renderOnZeroPageCount={() => null} and not renderOnZeroPageCount={null} like showed in doc. |
This now should be possible @equinusocio can you check one last time? |
Yes it works |
Thanks. @AdeleD we could release https://github.com/AdeleD/react-paginate/releases/tag/v8.0.2 |
@MonsieurV The CSS of the demo seems to be broken on my side. See: Maybe an issue with styled-component? |
@AdeleD I've committed everything Maybe as I changed quite a bit, ensure you do not get from cache (Bootstrap version is changed) and that you have You should have something like that: |
👌 I hadn't rebuilt the demo.js file properly, sorry. v8.0.2 is released. |
Using typescript here, when i add
renderOnZeroPageCount
the prop is not recognizedd:
The text was updated successfully, but these errors were encountered: