Skip to content

Commit

Permalink
refactor: use rc-util/lib/pickAttrs (#526)
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 authored May 28, 2023
1 parent 1e9f064 commit 3d69c07
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
},
"dependencies": {
"@babel/runtime": "^7.10.1",
"classnames": "^2.2.1"
"classnames": "^2.2.1",
"rc-util": "^5.32.2"
},
"devDependencies": {
"@types/classnames": "^2.2.9",
Expand Down
20 changes: 5 additions & 15 deletions src/Pagination.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint react/prop-types: 0 */
import classNames from 'classnames';
import pickAttrs from 'rc-util/lib/pickAttrs';
import React, { cloneElement, isValidElement } from 'react';
import KEYCODE from './KeyCode';
import LOCALE from './locale/zh_CN';
Expand Down Expand Up @@ -486,20 +486,10 @@ class Pagination extends React.Component<PaginationProps, PaginationState> {
const prevPage = current - 1 > 0 ? current - 1 : 0;
const nextPage = current + 1 < allPages ? current + 1 : allPages;

const dataOrAriaAttributeProps = Object.keys(this.props).reduce(
(prev, key) => {
if (
key.substr(0, 5) === 'data-' ||
key.substr(0, 5) === 'aria-' ||
key === 'role'
) {
// eslint-disable-next-line no-param-reassign
prev[key] = this.props[key];
}
return prev;
},
{},
);
const dataOrAriaAttributeProps = pickAttrs(this.props, {
aria: true,
data: true,
});

const totalText = showTotal && (
<li className={`${prefixCls}-total-text`}>
Expand Down

0 comments on commit 3d69c07

Please sign in to comment.