如何停止使用窗口时redux重置状态。打开以重定向URL
我有一个简单的登录页面,当信息正确时,我将用户通过window.open()用_sfly参数将用户重定向到另一个URL。例如:window.open(“/home”,“ _ self”);
问题是,我将此登录信息保存到redux商店,但是由于window.open(),自然而然地将redux重置了商店。的页面加载。我不能在登录按钮上使用链接。
因此,是否可以将不加载页面加载(不使用 link )重定向到另一个URL,或避免Redux Reset Reset状态操作?
I have a simple login page, when the informations are correct, I redirect the user to another url via window.open() with _self parameter. Eg: window.open("/home", "_self");
The problem is, I save this login information to the Redux store, but naturally Redux resets the store because of window.open()'s page load. I can't use Link on Login button.
So is it possible to redirect to another URL without page load (not using Link as I mentioned) or avoid Redux reset state action?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能需要使用 redux persist 它允许您将redux State存储在本地设备的存储以及您的React应用程序最初从Redux persist 或呈现您的Redux时,您可以通过查询参数来指示如类似的内容
并陷入查询参数中,并根据需要渲染组件。
希望这会有所帮助。
You might want to use Redux Persist which allows you to store your redux state in the local storage of your device and when your react app renders initially hydrate your redux from the redux persist OR you can pass in query param that indicates somethings like
and trap in the query param and render your component as needed.
Hope this helps.
我必须通过链接来解决它,将 参数的值与三元运算符相关。
I had to solve it via Link, giving to parameter's value with ternary operator.