mirror of
https://github.com/mickael-kerjean/filestash
synced 2026-01-03 06:17:35 +01:00
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:
parent
a0a8de2a8d
commit
f6394d1cd2
1 changed files with 1 additions and 26 deletions
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Reference in a new issue