Convert MovieTitleLink to TypeScript

Closes #10322
pull/10341/head
Bogdan 5 months ago
parent 540659a799
commit 644876123d

@ -1,33 +0,0 @@
import PropTypes from 'prop-types';
import React, { PureComponent } from 'react';
import Link from 'Components/Link/Link';
class MovieTitleLink extends PureComponent {
render() {
const {
titleSlug,
title,
year
} = this.props;
const link = `/movie/${titleSlug}`;
return (
<Link
to={link}
title={title}
>
{title}{year > 0 ? ` (${year})` : ''}
</Link>
);
}
}
MovieTitleLink.propTypes = {
titleSlug: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
year: PropTypes.number
};
export default MovieTitleLink;

@ -0,0 +1,26 @@
import React from 'react';
import Link, { LinkProps } from 'Components/Link/Link';
interface MovieTitleLinkProps extends LinkProps {
titleSlug: string;
title: string;
year?: number;
}
function MovieTitleLink({
titleSlug,
title,
year = 0,
...otherProps
}: MovieTitleLinkProps) {
const link = `/movie/${titleSlug}`;
return (
<Link to={link} title={title} {...otherProps}>
{title}
{year > 0 ? ` (${year})` : ''}
</Link>
);
}
export default MovieTitleLink;
Loading…
Cancel
Save