ComponentDidMount 在重定向回调之前被触发
ComponentDidMount getting triggered before redirect callback
我正在使用 React 框架。
当我使用 loginRedirect()
方法登录时,我被重定向回我提供的重定向 uri - https:localhost:3000
.
调用 componentDidMount()
时重定向(返回到我的页面)后,msalInstance.getAccount()
returns null 因为令牌尚未创建。
在此之后触发重定向回调。
componentDidMount()
在重定向回调和令牌创建触发器之前被调用。
因此,我必须在重定向后重新加载页面,以便 componentDidMount()
中的 msalInstance.getAccount()
有效。
我该如何处理这种情况?
你得到空值是因为你没有等待你的回应。尝试在 componentDidMount()
中使用 Promises 或 async/await
@azure/msal-browser 的 v2.0.0-beta 有问题。
随后在下一个版本-v2.0.0-beta.1
中修复
我正在使用 React 框架。
当我使用 loginRedirect()
方法登录时,我被重定向回我提供的重定向 uri - https:localhost:3000
.
调用 componentDidMount()
时重定向(返回到我的页面)后,msalInstance.getAccount()
returns null 因为令牌尚未创建。
在此之后触发重定向回调。
componentDidMount()
在重定向回调和令牌创建触发器之前被调用。
因此,我必须在重定向后重新加载页面,以便 componentDidMount()
中的 msalInstance.getAccount()
有效。
我该如何处理这种情况?
你得到空值是因为你没有等待你的回应。尝试在 componentDidMount()
中使用 Promises 或 async/await@azure/msal-browser 的 v2.0.0-beta 有问题。 随后在下一个版本-v2.0.0-beta.1
中修复