如何在reactJS中管理多选项卡注销?

问题描述 投票:0回答:1
window.addEventListener('storage', e => {
  if(e.key === 'access_token' && e.oldValue && !e.newValue) {
    store.dispatch(userSignOut());
  }
})

如果这是一个合适的解决方案,那么我应该将其粘贴到哪里(生命周期事件?]

javascript reactjs
1个回答
0
投票

enter link description here

尝试使用焦点侦听器isFocused

也请检查

反应导航向订阅它们的屏幕组件发出事件:

willFocus - the screen will focus
didFocus - the screen focused (if there was a transition, the transition 
completed)
willBlur - the screen will be unfocused
didBlur - the screen unfocused (if there was a transition, the transition 
completed)
© www.soinside.com 2019 - 2024. All rights reserved.