首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何定义...props接口?

如何定义...props接口?
EN

Stack Overflow用户
提问于 2019-04-11 03:29:21
回答 1查看 156关注 0票数 0

我在用

react-pagination (节点包)

所以我安装了@types/react-pagination

我为ReactPaginate创建了自定义组件

ReactPaginate有这么多道具。

所以我创建了...props,该对象包含ReactPaginate's道具。

@types/react-pagination有接口ReactPaginateProps

所以我试着

代码语言:javascript
复制
interface IProps {
  onPageChange?():any;
  props: ReactPaginateProps; // ❓❓❓
}


const MYPagination: React.SFC<IProps> = ({
  onPageChange, ...props
}) => {
<ReactPaginate {...props}/>
}

我希望如果...prop包括其中一个(ReactPaginateProps),然后键入ok!

请教我如何创建...pros's界面?

和反应分页道具界面是

代码语言:javascript
复制
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;

    /**
     * Label for the `next` button.
     */
    nextLabel?: React.ReactNode;

    /**
     * Label for ellipsis.
     */
    breakLabel?: string | React.ReactNode;

    /**
     * The classname on tag `li` of the ellipsis element.
     */
    breakClassName?: string;

    /**
     * The classname on tag `a` of the ellipsis element.
     */
    breakLinkClassName?: string;

    /**
     * The method to call when a page is clicked. Exposes the current page object as an argument.
     */
    onPageChange?(selectedItem: { selected: number }): void;

    /**
     * The initial page selected.
     */
    initialPage?: number;

    /**
     * To override selected page with parent prop.
     */
    forcePage?: number;

    /**
     * Disable onPageChange callback with initial page. Default: false
     */
    disableInitialCallback?: boolean;

    /**
     * The classname of the pagination container.
     */
    containerClassName?: string;

    /**
     * The classname on tag `li` of each page element.
     */
    pageClassName?: string;

    /**
     * The classname on tag `a` of each page element.
     */
    pageLinkClassName?: string;

    /**
     * The classname for the active page.
     */
    activeClassName?: string;

    /**
     * The classname for the active link.
     */
    activeLinkClassName?: string;

    /**
     * The classname on tag `li` of the `previous` button.
     */
    previousClassName?: string;

    /**
     * The classname on tag `li` of the `next` button.
     */
    nextClassName?: string;

    /**
     * The classname on tag `a` of the `previous` button.
     */
    previousLinkClassName?: string;

    /**
     * The classname on tag `a` of the `next` button.
     */
    nextLinkClassName?: string;

    /**
     * The classname for disabled `previous` and `next` buttons.
     */
    disabledClassName?: string;

    /**
     * The method is called to generate the href attribute value on tag a of each page element.
     */
    hrefBuilder?(pageIndex: number): void;

    /**
     * Extra context to add to the aria-label HTML attribute.
     */
    extraAriaContext?: string;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-11 03:40:11

代码语言:javascript
复制
interface IProps extends ReactPaginateProps {
  onPageChange?: () => any;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55624276

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档