Skip to content

Commit

Permalink
feat: have Page item forward ref (#4664)
Browse files Browse the repository at this point in the history
* [#4194] - Page item forward ref

* [#4194] - Page item displayName and prettier cleanup
  • Loading branch information
zhuber authored and jquense committed Oct 14, 2019
1 parent ed77ae7 commit 1baf794
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions src/PageItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,34 @@ const defaultProps = {
activeLabel: '(current)',
};

export default function PageItem({
active,
disabled,
className,
style,
activeLabel,
children,
...props
}) {
const Component = active || disabled ? 'span' : SafeAnchor;
return (
<li
style={style}
className={classNames(className, 'page-item', { active, disabled })}
>
<Component className="page-link" disabled={disabled} {...props}>
{children}
{active && activeLabel && (
<span className="sr-only">{activeLabel}</span>
)}
</Component>
</li>
);
}
const PageItem = React.forwardRef(
(
{ active, disabled, className, style, activeLabel, children, ...props },
ref,
) => {
const Component = active || disabled ? 'span' : SafeAnchor;
return (
<li
ref={ref}
style={style}
className={classNames(className, 'page-item', { active, disabled })}
>
<Component className="page-link" disabled={disabled} {...props}>
{children}
{active && activeLabel && (
<span className="sr-only">{activeLabel}</span>
)}
</Component>
</li>
);
},
);

PageItem.propTypes = propTypes;
PageItem.defaultProps = defaultProps;
PageItem.displayName = 'PageItem';

export default PageItem;

function createButton(name, defaultValue, label = name) {
return class extends React.Component {
Expand Down

0 comments on commit 1baf794

Please sign in to comment.