StarPicker
is the default export of the react-star-picker
module:
import React, { useState } from 'react';
import StarPicker from 'react-star-picker';
const ParentComponent = () => {
const [rating, setRating] = useState(null);
const onChange = (value) => {
setRating(value);
};
return (
<div>
<StarPicker onChange={onChange} value={rating} />
</div>
);
};
StarPicker
accepts the following props:
type StarPickerProps = {|
starRenderer: StarRendererFunction,
halfStars: boolean,
disabled: boolean,
size: number,
onChange: (index: ?number, name?: string) => void,
value: ?number,
name?: string,
className?: string,
starCount: number,
resettable: boolean,
|};
onChange
: function called with the selected value and the input name after a new pickvalue
: current value of the input
starRenderer
: if provided, replaces the default star-rendererhalfStars
: whether to use half-star precisiondisabled
: whether the input is disabledsize
: the size of the stars in px (used for font-size, button widths)name
: input's name, supplied to the onChange function if providedclassName
starCount
: number of stars in the inputresettable
: When true, picking the existing rating clears it