![](/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.