如何停止使用窗口时redux重置状态。打开以重定向URL

发布于 2025-01-31 03:45:13 字数 305 浏览 2 评论 0原文

我有一个简单的登录页面,当信息正确时,我将用户通过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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

过气美图社 2025-02-07 03:45:13

您可能需要使用 redux persist 它允许您将redux State存储在本地设备的存储以及您的React应用程序最初从Redux persist 呈现您的Redux时,您可以通过查询参数来指示如类似的内容

yoururl.com?isisroggedin=true

并陷入查询参数中,并根据需要渲染组件。

希望这会有所帮助。

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

yourURL.com?isLoggedIn=true

and trap in the query param and render your component as needed.

Hope this helps.

忆依然 2025-02-07 03:45:13

我必须通过链接来解决它,将 参数的值与三元运算符相关。

I had to solve it via Link, giving to parameter's value with ternary operator.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文