![](/img/trans.png)
[英]Github pages made with create-react-app + react-routers doesn't load in iOS devices
[英]react-routers take two - six times to redirect to other pages
(问题)react-router需要2到6次重定向到其他页面
这是我点击的链接。
<div className='drawer-item' onClick={this.drawerItemClicked}>
<BinaryLink to={link_to}>
<span className={icon || undefined}>{text}</span>
</BinaryLink>
</div>
单击项目(链接)时,将触发drawerItemClicked
项目点击。
drawerItemClicked = (e) => {
this.props.hideDrawers();
if (this.props.collapseItems) {
this.props.collapseItems();
}
}
同时, BinaryLink
被触发
export const BinaryLink = ({ to, children, ...props }) => {
const path = normalizePath(to);
const route = getRouteInfo(path);
console.log('to');
console.log(to); <- triggers continuously
if (!route) {
throw new Error(`Route not found: ${to}`);
}
return (
to ?
<NavLink to={path} activeClassName='active' exact={route.exact} {...props}>
{children}
</NavLink>
:
<a href='javascript:;' {...props}>
{children}
</a>
);
};
这是路由器类
const routes = [
{ path: '/', component: TradeApp, exact: true },
{ path: '/statement', component: Statement, is_authenticated: true },
{ path: '/account', component: LostPassword, is_authenticated: false },
];
const RouteWithSubRoutes = route => (
<Route
exact={route.exact}
path={route.path}
render={props => (
(route.is_authenticated && !Client.isLoggedIn()) ? // TODO: update styling of the message below
<a href='javascript:;' onClick={redirectToLogin}>{localize('Please login to view this page.')}</a> :
<route.component {...props} routes={route.routes} />
)}
/>
);
export const BinaryRoutes = () => routes.map((route, idx) => (
<RouteWithSubRoutes key={idx} {...route} />
));
发生了严重错误。 但是我无法排除故障。
从to
的输出to
继续调用route.js,因为它正在渲染服务器的当前时间。 但是,即使删除它,也无法正常工作。
...
routes.js:48 undefined
rroutes.js:47 to
routes.js:48 undefined
routes.js:47 to
routes.js:48 undefined
routes.js:47 to
routes.js:48 undefined
routes.js:47 to
routes.js:48 undefined
routes.js:47 to
routes.js:48 undefined
routes.js:47 to
routes.js:48 undefined
我的想法定义<NavLink>
地方肯定是错误的
原来有CSS错误。 <a>
标记未占用div
的整个空间。 我希望这能解决其他人的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.