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

TabBarItem is not update after receive new defaultIndex

Open cncolder opened this issue 8 years ago • 4 comments
trafficstars

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版本 机型和系统) [email protected], [email protected], all.

cncolder avatar Dec 30 '16 09:12 cncolder

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

n7best avatar Dec 30 '16 17:12 n7best

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

cncolder avatar Dec 31 '16 05:12 cncolder

这里就好了

n7best avatar Dec 31 '16 06:12 n7best

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

zhj135 avatar Jun 16 '17 02:06 zhj135