import React from 'react'; import withWidth from '@material-ui/core/withWidth'; import Typography from '@material-ui/core/Typography'; import { Breakpoint } from '@material-ui/core/styles/createBreakpoints'; type TagName = 'em' | 'u' | 'del'; const components: Partial> = { sm: 'em', md: 'u', lg: 'del', }; function WithWidth(props: { width: Breakpoint }) { const { width } = props; const Component = components[width] || 'span'; return ( {`Current width: ${width}`} ); } export default withWidth()(WithWidth);