element-react icon indicating copy to clipboard operation
element-react copied to clipboard

Component Menu not display correct current active Menu Item when using this.props.history.push

Open grepug opened this issue 7 years ago • 2 comments

I use component Menu with React-router v4 and its Hight order component withRouter. When I put something like this.props.history() in the Menu's prop onSelect, the current active Menu item displays incorrectly, that's to say, the prop activeIndex changes incorrectly.

so I searched code in the library, I found that in Menu.jsx

  componentWillReceiveProps(props: Object) {
    if (props.defaultActive != this.props.defaultActive || props.defaultActive != this.state.activeIndex) {
      this.defaultActiveChanged(props.defaultActive);
    }

    if (props.defaultOpeneds != this.props.defaultOpeneds) {
      this.defaultOpenedsChanged(props.defaultOpeneds);
    }
  }

I removed props.defaultActive != this.state.activeIndex in the first if condition, everything is good.

So, I want the owner to check if there is something wrong, or explain how To do to navigate path with react router v4 with Menu component.

Thank you!

grepug avatar May 03 '18 04:05 grepug

Same problem here.

brenohq avatar Sep 16 '19 17:09 brenohq

Same problem here.

xuexing9527 avatar Dec 13 '19 08:12 xuexing9527