[英]React-Router - Can i get the next path string in browser history of react router or check if there is somthing forward?
I'm making an application on Electron with React, and i want to replicate the functionality of navegation in the browser. 我正在用React在Electron上制作一个应用程序,我想在浏览器中复制导航的功能。
I have a goBack and goForward button, and i want to disable the goForward when there is nothing on next and disable the goBack when there is nothgin on back, just like the browsers do it. 我有一个goBack和goForward按钮,我想在下一个什么都没有的时候禁用goForward,而在后面没有空的时候禁用goBack,就像浏览器一样。
So i have react-router, im doint that with 所以我有react-router,我用
browserHistory.goBack() browserHistory.goForward()
So i want a way to detect that is nothig next and disable the button. 所以我想要一种方法来检测nothig接下来并禁用按钮。 Can be geeting the next and back path string or checking if there is something.
可以选择下一个和后一个路径字符串,或者检查是否有东西。
根据历史记录文档https://github.com/mjackson/history#navigation,您可以使用canGo(n)
来检查该动作是否可能,我认为应该是canGo(1)
来检查是否可以前进和canGo(-1)
当后退
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.