weui / react-weui

weui for react
https://weui.github.io/react-weui/docs/
2.85k stars 492 forks source link

TabBarItem is not update after receive new defaultIndex #181

Open cncolder opened 7 years ago

cncolder commented 7 years ago

Do you want to request a feature or report a bug (建议还是bug) ? bug

What is the current behavior? (现有状况) https://github.com/weui/react-weui/blob/master/src/components/tab/tab.js#L38 Can't change defaultIndex after first render.

What is the expected behavior? (应有状况) Update this.state.index after receive new props.

componentWillReceiveProps(nextProps) {
  if (this.props.defaultIndex != nextProps.defaultIndex) {
    this.setState({index: nextProps.defaultIndex})
  }
}

Which versions of React-weui, weui, and which OS and device are affected by this issue? (React-weui版本 weui版本 机型和系统) react-weui@1.0.3, weui@1.1.0, all.

n7best commented 7 years ago

有遇到这个问题 可以发个pr吗

cncolder commented 7 years ago

@n7best pr发到这里还是你的fork?

n7best commented 7 years ago

这里就好了

zhj135 commented 7 years ago

Searchbar组件也有这个问题,是团队遗漏了还是有什么特殊的考虑呢?