1
0
mirror of https://github.com/SomboChea/ui synced 2026-01-17 00:25:50 +07:00

fix: listItem Component - Introduced ForwardRef (#183)

* refactor: introduced forwardRef

* fix: fixed button prop listItem

* chore: rollback package upgrade

* fix: fixed snap
This commit is contained in:
Priscila Oliveira
2019-10-12 21:11:23 +02:00
committed by Juan Picado @jotadeveloper
parent d2c1130efd
commit 82d7107de7
16 changed files with 43 additions and 27 deletions

View File

@@ -0,0 +1,20 @@
import React, { forwardRef } from 'react';
import { default as MaterialUIListItem, ListItemProps } from '@material-ui/core/ListItem';
type ListItemRef<T extends boolean = false> = T extends true ? HTMLDivElement : HTMLLIElement;
interface Props<T extends boolean = false> extends Omit<ListItemProps, 'button'> {
button?: T;
}
const ListItem = forwardRef(function ListItem<T extends boolean>({ button, ...props }: Props<T>, ref: React.Ref<ListItemRef<T>>) {
// it seems typescript has some discrimination type limitions. Please see: https://github.com/mui-org/material-ui/issues/14971
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return <MaterialUIListItem {...props} button={button as any} innerRef={ref} />;
});
ListItem.defaultProps = {
button: false,
};
export default ListItem;

View File

@@ -0,0 +1 @@
export { default } from './ListItem';