Ver Fonte

Avoid using null

itizawa há 5 anos atrás
pai
commit
fb5e5d85f4
1 ficheiros alterados com 6 adições e 2 exclusões
  1. 6 2
      src/client/js/components/PaginationWrapper.jsx

+ 6 - 2
src/client/js/components/PaginationWrapper.jsx

@@ -21,8 +21,11 @@ const PaginationWrapper = React.memo((props) => {
    * various numbers used to generate pagination dom
    * various numbers used to generate pagination dom
    */
    */
   const paginationNumbers = useMemo(() => {
   const paginationNumbers = useMemo(() => {
+    // avoid using null
+    const limit = pagingLimit || Infinity;
+
     // calc totalPageNumber
     // calc totalPageNumber
-    const totalPage = Math.floor(totalItemsCount / pagingLimit) + (totalItemsCount % pagingLimit === 0 ? 0 : 1);
+    const totalPage = Math.floor(totalItemsCount / limit) + (totalItemsCount % limit === 0 ? 0 : 1);
 
 
     let paginationStart = activePage - 2;
     let paginationStart = activePage - 2;
     let maxViewPageNum = activePage + 2;
     let maxViewPageNum = activePage + 2;
@@ -158,7 +161,7 @@ PaginationWrapper.propTypes = {
   activePage: PropTypes.number.isRequired,
   activePage: PropTypes.number.isRequired,
   changePage: PropTypes.func.isRequired,
   changePage: PropTypes.func.isRequired,
   totalItemsCount: PropTypes.number.isRequired,
   totalItemsCount: PropTypes.number.isRequired,
-  pagingLimit: PropTypes.number.isRequired,
+  pagingLimit: PropTypes.number,
   align: PropTypes.string,
   align: PropTypes.string,
   size: PropTypes.string,
   size: PropTypes.string,
 };
 };
@@ -166,6 +169,7 @@ PaginationWrapper.propTypes = {
 PaginationWrapper.defaultProps = {
 PaginationWrapper.defaultProps = {
   align: 'left',
   align: 'left',
   size: 'md',
   size: 'md',
+  pagingLimit: Infinity,
 };
 };
 
 
 export default PaginationWrapper;
 export default PaginationWrapper;