Intercept/handle browser's back button in React-router?

前端 未结 12 1078
滥情空心
滥情空心 2020-11-27 03:47

I\'m using Material-ui\'s Tabs, which are controlled and I\'m using them for (React-router) Links like this:

    

        
12条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-27 04:23

    I used withrouter hoc in order to get history prop and just write a componentDidMount() method:

    componentDidMount() {
        if (this.props.history.action === "POP") {
            // custom back button implementation
        }
    }
    

提交回复
热议问题