diff --git a/src/FilterLists.Web.V2/src/components/ListInfoDrawer.tsx b/src/FilterLists.Web.V2/src/components/ListInfoDrawer.tsx index 54fe5df6f..68e76212e 100644 --- a/src/FilterLists.Web.V2/src/components/ListInfoDrawer.tsx +++ b/src/FilterLists.Web.V2/src/components/ListInfoDrawer.tsx @@ -1,6 +1,6 @@ import { Divider, Drawer } from 'antd'; import ButtonGroup from 'antd/lib/button/button-group'; -import React from 'react'; +import React, { useEffect, useState } from 'react'; import { RouteComponentProps } from 'react-router-dom'; import { Language } from '../interfaces/Language'; @@ -21,108 +21,91 @@ interface Props { tags: Tag[]; }; -interface State { - baseDocumentTitle: string; -} +export const ListInfoDrawer = (props: RouteComponentProps & Props) => { + const [originalTitle] = useState(document.title); -export class ListInfoDrawer extends React.Component { - constructor(props: any) { - super(props); - this.state = { - baseDocumentTitle: document.title - }; - } + useEffect(() => { + const updateTitle = () => { + document.title = props.list.name + " | " + originalTitle; + } + updateTitle(); + return () => { document.title = originalTitle; } + }, [props.list, originalTitle]); - componentDidMount() { - this.updateTitle(); - } - - render() { - return this.props.history.push("/")}> - - {this.props.list.languageIds - ? + onClose={() => props.history.push("/")}> + + {props.list.languageIds + ? : null} - {this.props.list.tagIds - ? + {props.list.tagIds + ? : null} - {this.props.license - ? + {props.license + ? : null} - {this.props.list.publishedDate + {props.list.publishedDate ?

First Published Date:

- {new Date(this.props.list.publishedDate).toDateString()} + {new Date(props.list.publishedDate).toDateString()}
: null} - {this.props.list.viewUrl && } - {this.props.list.viewUrl && - } + {props.list.viewUrl && + } - {this.props.list.homeUrl && - } - {this.props.list.policyUrl && - } - {this.props.list.emailAddress && - } - {this.props.list.issuesUrl && - } - {this.props.list.submissionUrl && - } - {this.props.list.forumUrl && - } - {this.props.list.chatUrl && - } - {this.props.list.donateUrl && - }
- } - - componentDidUpdate() { - this.updateTitle(); - } - - private updateTitle() { - document.title = this.props.list.name + " | " + this.state.baseDocumentTitle; - } - - componentWillUnmount() { - document.title = this.state.baseDocumentTitle - } + ) } \ No newline at end of file