fix (back): longstanding issue with back button

the call to unlisten was removing the navigation from react router
altogether instead of it being local to the component itself. Somehow
we can't unlisten to the local component level so we got rid of the
entire back button altogether
This commit is contained in:
Mickael Kerjean 2022-10-11 08:45:58 +11:00
parent a0a8de2a8d
commit f6394d1cd2

View file

@ -54,21 +54,9 @@ export function ErrorPage(WrappedComponent) {
error: null,
trace: null,
showTrace: false,
has_back_button: false,
};
}
componentDidMount() {
this.unlisten = this.props.history.listen(() => {
this.setState({ has_back_button: false });
this.unlisten();
});
}
componentWillUnmount() {
if (this.unlisten) this.unlisten();
}
update(obj) {
this.setState({
error: obj,
@ -76,25 +64,12 @@ export function ErrorPage(WrappedComponent) {
});
}
navigate(e) {
if (this.state.has_back_button) {
e.preventDefault();
this.props.history.goBack();
}
}
render() {
if (this.state.error !== null) {
const message = this.state.error.message || t("There is nothing in here");
return (
<div>
<a href="/"
className="backnav" onClick={this.navigate.bind(this)}
>
<Icon name="arrow_left" />{
this.state.has_back_button ? "back" : "home"
}
</a>
<a href="/" className="backnav"><Icon name="arrow_left" />home</a>
<Container>
<div
className="error-page"