Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/367.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 主页的React路由器活动类_Javascript_Reactjs_React Router_React Router Dom_React Router Component - Fatal编程技术网

Javascript 主页的React路由器活动类

Javascript 主页的React路由器活动类,javascript,reactjs,react-router,react-router-dom,react-router-component,Javascript,Reactjs,React Router,React Router Dom,React Router Component,我有一个导航,我很难尝试风格。我已经能够将活动类添加到导航元素中,并对其应用样式,但是当我单击主仪表板(用作主页)时,它并没有应用专用的活动类。在应用程序中进行了一点挖掘之后,我认为AppRouter.js或routeConfig.js可能是问题所在 导航元素显示在下面的Navlink代码中: renderNavigationItem = (navigationItem) => { const { classes } = this.props; const { id,

我有一个导航,我很难尝试风格。我已经能够将活动类添加到导航元素中,并对其应用样式,但是当我单击主仪表板(用作主页)时,它并没有应用专用的活动类。在应用程序中进行了一点挖掘之后,我认为AppRouter.js或routeConfig.js可能是问题所在

导航元素显示在下面的Navlink代码中:

  renderNavigationItem = (navigationItem) => {
    const { classes } = this.props;
    const { id, name, parentUrlLink } = navigationItem;
    return (
      <NavLink exact key={id.toString()} to={{ pathname: parentUrlLink }} className="desk-link" 
      activeClassName='is-active'>
        <MenuItem className={classes.fontBoldHeader}>{name}</MenuItem>
      </NavLink>
    );
  }

你的主页也是导航链接吗?你能告诉我你在哪里使用
renderNavigationItem
?@vishnusandhireddy我想是这样的。我在任何地方都看不到代码otherwise@ShmiliBreuer请参见已编辑的问题。谢谢
class AppRouter extends Component {
  constructor(props, context) {
    super(props);
    this.context = context;
  }

  render() {
    const { account } = this.context;
    return (
      <Switch>
        {account ? <Redirect exact from="/" to={{ pathname: '/dashboard' }} /> : <Route exact path="/" component={Home} />}
        {routes.map((item) => <PrivateRoute {...item} key={`${item.path}-route`} />)}
        <Route path="/sessiontimeout" render={(props) => <TimedOutPage {...props} />} />
        <Route path="/500" render={(props) => <Error errorCode="500" {...props} />} />
        <Route path="/503" render={(props) => <Error errorCode="503" {...props} />} />
        <Route path="*" render={(props) => <Error errorCode="404" {...props} />} />
      </Switch>
    );
  }
}
renderNavigation = () => {
    const { menuNavigation } = this.props;
    return menuNavigation.map((item) => {
      if (item.children.length > 0) {
        return this.renderNavigationItemWithSubNav(item);
      }
      return this.renderNavigationItem(item);
    });
  }