ReactRouterDom,页面变化时触发事件
我有一个组件是导航栏。导航栏在我项目的特定部分中的所有屏幕中都持续存在,并且是所有给定时间的最高级别组件。
是否有可能以某种方式获得页面更改事件(因此,如果我从Show, /Main /Wiewer转到 /MAIN /DOCUMENTS)而又不会触发从导航栏从导航栏到查看器组件的PageChange而不触发PageChange?
这些组件彼此嵌套,因为Navbar显示主屏幕,然后将其引导到不同屏幕的不同组件,而这些组件又具有基于按钮的按钮等
。获取页面更改事件的方法,以便我可以在观看器中触发功能,该函数会提示保存完成的任何编辑,如果要通过NAV-BAR(或其他方式)更改页面,而不是通过按钮中的按钮观众。
当前,我通过使用this。,props.torsory
,然后.push(“ path”,props)
and code> .goback()在页面/组件之间导航。 通常是处理退出组件的函数上的最后一行。
I have a component that is a navigation bar. The navigation bar persists within all screens in specific parts of my project, and is the highest level component at all given times.
Is it possible to somehow get a page-change event (so if I go from say, /main/viewer to /main/documents ) without having a callback triggering a pagechange going from navigation bar all the way down to the viewer component?
These components are nested in each other, as the NavBar displays main screen, which then directs to different component for different screens, which in turn have components that call different screens based on buttons pressed, etc etc.
I'm trying to get the simplest way to get a page-change event, so that I can trigger a function in viewer, which prompts to save any edits done, if page is about to be changed through the nav-bar (or another means) and not via a button in the viewer.
currently, I navigate between pages/components by using this.,props.history
and then either .push("path", props)
and .goBack()
which is usually the last line on a function to handle exiting the component.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论