I have a Component that works as follows.
export default class BackButton extends Component {
back() {
window.history.back()
}
render() {
return (
<Button
icon={<ArrowLeft/>}
onTouchTap={this.back.bind(this)}
/>
)
}
}
This works perfectly well, but there is an "edge case". If you pop from the stack enough, it might lead to being stuck at a certain state without being able to go back because the stack is empty. When that happens, I want to be able to perform some additional functionality and disable the back button.
<Button
icon={<ArrowLeft/>}
disabled={!hasMoreHistory}
onTouchTap={this.back.bind(this)}
onHistoryEmpty={() => callback ? callback() : Router.go('/')}
/>
Is there a way to do this with javascript?