update document title on drawer open/close

This commit is contained in:
Collin M. Barrett 2019-08-25 17:19:57 -05:00
parent 8185a34676
commit 7087e100ba

View file

@ -10,11 +10,33 @@ interface Props {
list: List;
};
export const ListDetailsDrawer = (props: RouteComponentProps & Props) =>
<Drawer
visible={true}
onClose={() => props.history.push("/")}>
<h2>{props.list.name}</h2>
<Description {...props.list} />
<SubscribeButton {...props.list} />
</Drawer>;
interface State {
baseDocumentTitle: string;
}
export class ListDetailsDrawer extends React.Component<RouteComponentProps & Props, State> {
constructor(props: any) {
super(props);
this.state = {
baseDocumentTitle: document.title
};
}
componentDidMount() {
document.title = this.props.list.name + " | " + this.state.baseDocumentTitle
}
render() {
return <Drawer
visible={true}
onClose={() => this.props.history.push("/")}>
<h2>{this.props.list.name}</h2>
<Description {...this.props.list} />
<SubscribeButton {...this.props.list} />
</Drawer>
}
componentWillUnmount() {
document.title = this.state.baseDocumentTitle
}
}