
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
react-star-rating-component
Advanced tools
React component for star (or any other icon based) ratings
Tiny React.js component for star (or any other icon based) ratings.
npm install react-star-rating-component --save
<StarRatingComponent
name={String} /* name of the radio input, it is required */
value={Number} /* number of selected icon (`0` - none, `1` - first) */
starCount={Number} /* number of icons in rating, default `5` */
onStarClick={Function(nextValue, prevValue, name)} /* on icon click handler */
onStarHover={Function(nextValue, prevValue, name)} /* on icon hover handler */
onStarHoverOut={Function(nextValue, prevValue, name)} /* on icon hover out handler */
renderStarIcon={Function(nextValue, prevValue, name)} /* it should return string or react component */
renderStarIconHalf={Function(nextValue, prevValue, name)} /* it should return string or react component */
starColor={String} /* color of selected icons, default `#ffb400` */
emptyStarColor={String} /* color of non-selected icons, default `#333` */
editing={Boolean} /* is component available for editing, default `true` */
/>
import React from 'react';
import ReactDOM from 'react-dom';
import StarRatingComponent from 'react-star-rating-component';
class App extends React.Component {
constructor() {
super();
this.state = {
rating: 1
};
}
onStarClick(nextValue, prevValue, name) {
this.setState({rating: nextValue});
}
render() {
const { rating } = this.state;
return (
<div>
<h2>Rating from state: {rating}</h2>
<StarRatingComponent
name="rate1"
starCount={10}
value={rating}
onStarClick={this.onStarClick.bind(this)}
/>
</div>
);
}
}
ReactDOM.render(
<App />,
document.getElementById('app')
);
import React from 'react';
import ReactDOM from 'react-dom';
import StarRatingComponent from 'react-star-rating-component';
class App extends React.Component {
render() {
const { rating } = this.state;
return (
<div>
<h2>Rating from state: {rating}</h2>
<StarRatingComponent
name="rate2"
editing={false}
renderStarIcon={() => <span></span>}
starCount={10}
value={8}
/>
</div>
);
}
}
ReactDOM.render(
<App />,
document.getElementById('app')
);
Check more in examples folder.
MIT Licensed
FAQs
React component for star (or any other icon based) ratings
The npm package react-star-rating-component receives a total of 8,782 weekly downloads. As such, react-star-rating-component popularity was classified as popular.
We found that react-star-rating-component demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.