Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support rate props to control UI. #16

Closed
ellemedit opened this issue Jul 13, 2016 · 2 comments
Closed

Support rate props to control UI. #16

ellemedit opened this issue Jul 13, 2016 · 2 comments

Comments

@ellemedit
Copy link

This component can't cancel rate if user rated.
To solve this, rate props is needed.

@dreyescat
Copy link
Owner

If I am not wrong, what you mean is having a controlled react rating. You can create a wrapper component that maintains the rate value in its own internal state. Then, you can use whatever you want to reset the rating, for example, a reset button:

var MyComponent = React.createClass({
  getInitialState: function () {
    return {
      rate: undefined
    };
  },
  onReset: function () {
    this.setState({rate: undefined});
  },
  onChange: function (rate) {
    this.setState({rate: rate});
  },
  render: function () {
    return (
        <div>
            <Rating onChange={this.onChange} initialRate={this.state.rate} />
            <button onClick={this.onReset}>Reset</button>
        </div>
    );
  }
});

Check this rating reset example.

Hope I did not misunderstand your comment 😉.

@ellemedit
Copy link
Author

Oops! I misunderstood this component. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants