For the following typescript code
import React from 'react';
import classnames from 'classnames';
import { ClassValue } from 'classnames/types';
type Props = {
children: React.ReactNode;
className: ClassValue;
tag?: React.ElementType;
style?: React.CSSProperties;
};
const Component: React.FunctionComponent<Props> = ({ tag: Tag, className, children, ...props }) => (
<Tag { ...props } className={ classnames('component', className) }>
{ children }
</Tag>
);
Component.defaultProps = {
tag: 'div',
};
export default Component;
Why <Tag
can be used but not <tag
? Isn't tag the parameter of the function and Tag is the type of it? What syntax being used here?