diff --git a/packages/ra-ui-materialui/src/detail/Tab.js b/packages/ra-ui-materialui/src/detail/Tab.tsx similarity index 83% rename from packages/ra-ui-materialui/src/detail/Tab.js rename to packages/ra-ui-materialui/src/detail/Tab.tsx index 0202ea53ee1..ecfcf3c84ce 100644 --- a/packages/ra-ui-materialui/src/detail/Tab.js +++ b/packages/ra-ui-materialui/src/detail/Tab.tsx @@ -1,22 +1,13 @@ import * as React from 'react'; -import { isValidElement } from 'react'; +import { isValidElement, ReactElement, ReactNode } from 'react'; import PropTypes from 'prop-types'; import { Link } from 'react-router-dom'; -import MuiTab from '@material-ui/core/Tab'; -import { useTranslate } from 'ra-core'; +import MuiTab, { TabProps as MuiTabProps } from '@material-ui/core/Tab'; +import { useTranslate, Record } from 'ra-core'; import classnames from 'classnames'; import Labeled from '../input/Labeled'; -const sanitizeRestProps = ({ - contentClassName, - label, - icon, - value, - translate, - ...rest -}) => rest; - /** * Tab element for the SimpleShowLayout. * @@ -71,7 +62,7 @@ const Tab = ({ resource, value, ...rest -}) => { +}: TabProps) => { const translate = useTranslate(); const renderHeader = () => ( @@ -81,16 +72,15 @@ const Tab = ({ value={value} icon={icon} className={classnames('show-tab', className)} - component={Link} - to={value} - {...sanitizeRestProps(rest)} + {...({ component: Link, to: value } as any)} // to avoid TypeScript screams, see https://github.com/mui-org/material-ui/issues/9106#issuecomment-451270521 + {...rest} /> ); const renderContent = () => ( {React.Children.map(children, field => - field && isValidElement(field) ? ( + field && isValidElement(field) ? (