reactjs - 路由重定向到反应路由器中陷入循环的外部链接
问题描述
从反应应用程序中,我正在调用带有反应路由器的外部链接,如下所示
<PrivateRoute exact path='/a/b' component={() => {
window.location = `https://externallink/a/b`;
return null;
}}/>
重定向正在工作,但它陷入了循环。它无限期地调用外部链接。我怎样才能停止循环。
解决方案
尝试这个
<PrivateRoute exact path='/a/b' component={() => {
useEffect(()=>{
const redirectLink = `https://externallink/a/b`
window.location !== redirectLink
&& window.location = redirectLink
},[])
return null;
}}/>
推荐阅读
- speech-recognition - 如何确定语音识别中 HMM 的观察序列长度
- powerbi-desktop - PowerBI:显示除第一个季度外的前 5 个季度
- reactjs - 如何整合react?
- javascript - 从 jqgrid 获取特定数据
- cordova - 使用 Firestore 的 Cordova 应用程序无法在某些设备上运行
- c# - C# 绘制简单连接对象的图表
- java - Java 计数器问题
- node.js - 用于链式方法的 Sinon 存根
- angular - (角度)输入文本事件绑定与双向绑定之间是否有任何性能改进?
- python - 从主文件夹的子文件夹中随机提取文件