Skip to content

绑定数据,星级不跟随数据变化 #1

Description

@chenyinlong

查看源码:
this.state = { rating: props.rating || 0 };
你将props数据赋值在state上,造成不能辩护;
请更新代码
`render() {
let extraProps = this.props.viewOnly ? {} : this.panResponder.panHandlers;

return (
  <View
    onLayout={event => {
      const layout = event.nativeEvent.layout;
      this.viewX = layout.x;
    }}
    style={{ flexDirection: 'row' }}
    {...extraProps}
  >
    // {this._getStars(this.state.rating)}
     {this._getStars(this.props.rating)}
  </View>
);

}`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions