Skip to content

Commit

Permalink
fix(DropdownItem): simplify component type (#6659)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyletsang committed Jul 16, 2023
1 parent 6bb3842 commit d25e5f9
Showing 1 changed file with 39 additions and 41 deletions.
80 changes: 39 additions & 41 deletions src/DropdownItem.tsx
@@ -1,7 +1,7 @@
import classNames from 'classnames';
import PropTypes from 'prop-types';
import * as React from 'react';
import BaseDropdownItem, {
import {
useDropdownItem,
DropdownItemProps as BaseDropdownItemProps,
} from '@restart/ui/DropdownItem';
Expand Down Expand Up @@ -45,47 +45,45 @@ const propTypes = {
as: PropTypes.elementType,
};

const DropdownItem: BsPrefixRefForwardingComponent<
typeof BaseDropdownItem,
DropdownItemProps
> = React.forwardRef(
(
{
bsPrefix,
className,
eventKey,
disabled = false,
onClick,
active,
as: Component = Anchor,
...props
},
ref,
) => {
const prefix = useBootstrapPrefix(bsPrefix, 'dropdown-item');
const [dropdownItemProps, meta] = useDropdownItem({
key: eventKey,
href: props.href,
disabled,
onClick,
active,
});
const DropdownItem: BsPrefixRefForwardingComponent<'a', DropdownItemProps> =
React.forwardRef(
(
{
bsPrefix,
className,
eventKey,
disabled = false,
onClick,
active,
as: Component = Anchor,
...props
},
ref,
) => {
const prefix = useBootstrapPrefix(bsPrefix, 'dropdown-item');
const [dropdownItemProps, meta] = useDropdownItem({
key: eventKey,
href: props.href,
disabled,
onClick,
active,
});

return (
<Component
{...props}
{...dropdownItemProps}
ref={ref}
className={classNames(
className,
prefix,
meta.isActive && 'active',
disabled && 'disabled',
)}
/>
);
},
);
return (
<Component
{...props}
{...dropdownItemProps}
ref={ref}
className={classNames(
className,
prefix,
meta.isActive && 'active',
disabled && 'disabled',
)}
/>
);
},
);

DropdownItem.displayName = 'DropdownItem';
DropdownItem.propTypes = propTypes;
Expand Down

0 comments on commit d25e5f9

Please sign in to comment.