Files
SCM-Manager/scm-ui/ui-components/src/layout/Title.tsx

31 lines
618 B
TypeScript
Raw Normal View History

2019-12-12 16:25:33 +01:00
import React, { FC, useEffect } from "react";
type Props = {
title?: string;
2019-12-12 16:25:33 +01:00
customPageTitle?: string;
preventRefreshingPageTitle?: boolean;
};
2019-12-12 16:25:33 +01:00
const Title: FC<Props> = ({ title, preventRefreshingPageTitle, customPageTitle }) => {
useEffect(() => {
if (!preventRefreshingPageTitle) {
if (customPageTitle) {
document.title = customPageTitle;
} else if (title) {
document.title = title;
}
}
2019-12-12 16:25:33 +01:00
});
if (title) {
return <h1 className="title">{title}</h1>;
}
2019-12-12 16:25:33 +01:00
return null;
};
Title.defaultProps = {
preventRefreshingPageTitle: false
};
export default Title;