How to use a custom component with react-router route transitions?

前端 未结 5 1565
生来不讨喜
生来不讨喜 2021-02-08 11:25

The article Confirming Navigation explains how to use a browser confirmation box in your transition hook. Fine. But I want to use my own Dialog box. If I were to use the methods

5条回答
  •  猫巷女王i
    2021-02-08 12:02

    Above is great except when user goes back in history. Something like the following should fix the problem:

    if (!withinHook && nextLocation) {
        if (nextLocation.action=='POP') {
            router.goBack()
        } else {
          router.push(nextLocation)
        }
    }
    

提交回复
热议问题