Show the average satisfaction of a feature
Show how many people love your feature:
1function FeatureRating({ triggerKey }) {
2 const { getAverageRating } = useVibeReview();
3 const [stats, setStats] = useState(null);
4
5 useEffect(() => {
6 getAverageRating(triggerKey).then(setStats);
7 }, [triggerKey]);
8
9 if (!stats || stats.totalRatings === 0) {
10 return <span>No ratings yet</span>;
11 }
12
13 return (
14 <div className="rating-badge">
15 ⭐ {stats.averageRating.toFixed(1)} / 5
16 <small>({stats.totalRatings} people)</small>
17 </div>
18 );
19}1<button>Export to PDF</button>
2<FeatureRating triggerKey="export-pdf" />
3
4// Shows: ⭐ 4.3 / 5 (127 people)