React UI Components Documentation
The React Rating allows you to choose a rating. This guide adds the React Rating (jqxRating) to an app, then shows how to set its options, handle its events and call its methods.
jqwidgets-scriptsjqwidgets-scripts/jqwidgets-react-tsx/jqxrating 
In a React project (to start one, see Getting started with React), add the package:
npm install jqwidgets-scripts
import JqxRating from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxrating';
import 'jqwidgets-scripts/jqwidgets/styles/jqx.base.css';
import 'jqwidgets-scripts/jqwidgets/styles/jqx.tailwind-blue-dark.css';
jqx.base.css is required. The second file is a theme; pick one of the jqx.*.css files (material, fluent, light, dark and more) and pass its name to the theme prop.
The source of the live Default Functionality demo:
import { useRef, useCallback } from 'react';
import JqxRating from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxrating';
interface RatingChangeEvent {
value: number;
}
function App() {
const rateRef = useRef<HTMLDivElement>(null);
const handleChange = useCallback((event: RatingChangeEvent) => {
if (rateRef.current) {
rateRef.current.textContent = String(event.value);
}
}, []);
return (
<div style={{ fontSize: '13px', fontFamily: 'Verdana' }}>
<JqxRating onChange={handleChange} width={350} height={35} />
<div style={{ marginTop: '10px', float: 'left' }}>
<div>Rating: </div>
<div ref={rateRef} />
</div>
</div>
);
}
export default App;
Options are props. Keep objects such as the data adapter and the columns stable across renders with useMemo, so the component does not reload them.
Each event is a prop named on plus the event name with a capital first letter. For example, change: The change event is triggered when the rating is changed.
const handleChange = (event: any): void => {
console.log(event.args);
};
return <JqxRating onChange={handleChange} />;
Call methods through a ref. For example, val: Sets or gets the value.
import { useRef } from 'react';
const myRating = useRef<JqxRating>(null);
const onClick = () => {
const value = myRating.current!.val();
console.log(value);
};
return <JqxRating ref={myRating} />;
Every component also has setOptions({ … }) and getOptions('name'), to change or read options after the first render.