Giter VIP home page Giter VIP logo

Comments (3)

dreyescat avatar dreyescat commented on August 19, 2024

Uhm... I am always wary of the idea of adding more properties. Yes, the example plugin is really nice! It is a great job! It has an option for anything you can imagine 😄. You have options for a clear button, captions, star captions, etc. And, hence, to give you more flexibility, many other properties to customize text and style of those options. It is a way. Giving you a full-featured component. It is Ok. Nothing against it.

But I prefer the other way. Let's call the react way. Give you the basics and let you compose your own. Create a new component that manages the Rating state at your will. With a reset button, for example:

// ResetRating
class ResetRating extends React.Component {
  constructor(props) {
    super(props);
    this.state = {value: 0};

    this.handleClick = this.handleClick.bind(this);
  }

  handleClick(event) {
    this.setState({value: 0});
  }

  render() {
    return (
      <div>
        <Rating {...this.props} initialRating={this.state.value} />
        <button onClick={this.handleClick}>Reset</button>
      </div>
    );
  }
}

You are not limited to a specific way of resetting your value. Let your imagination fly 😉.

from react-rating.

dreyescat avatar dreyescat commented on August 19, 2024

You can see it in action in the demo page.

from react-rating.

davidklebanoff avatar davidklebanoff commented on August 19, 2024

Sounds good, thanks!

from react-rating.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.