我有一个Redux
应用程序,它使用redux-persist
来存储auth jwt token。该应用程序将从redux存储中获取token,并将其放入HTTP Authorization
标头。
这里的问题是,每当我在另一个选项卡中登录到其他用户时,redux存储不会使用新登录的用户令牌进行更新。(尽管localStorage
使用新登录的用户令牌进行更新)
所以我想知道是否有一个最佳实践来做到这一点,通过设置一些选项redux-persist
?
或者我需要添加一个localStorage侦听器来更新redux存储每当有一个localStorage更改?
我希望我的解释是可以理解的。
谢谢你
1条答案
按热度按时间de90aj5v1#
不,没有内置的API!
可以使用
storage
事件:其他选项是
redux-state-sync
包。redux-state-sync
是redux
的middleware
在这个例子中,当计数器在
localstorage
中改变时,所有选项卡将接收新状态值!please see this link for more info!