Skip to content

Commit

Permalink
Memoized RatingBar component
Browse files Browse the repository at this point in the history
  • Loading branch information
webdevsk committed Oct 4, 2023
1 parent 52afd4c commit a498cd2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/RatingBar.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { memo } from "react"
import "./ratingBar.css"

const RatingBar = ({ rating }) => (
const RatingBar = memo(({ rating }) => (
<div className="rating-bar relative flex w-max">
<div
style={{ width: `${(rating / 5) * 100 ?? 0}%` }}
Expand All @@ -25,6 +26,7 @@ const RatingBar = ({ rating }) => (
</svg>
))}
</div>
)
))

RatingBar.displayName = "RatingBar"
export default RatingBar

0 comments on commit a498cd2

Please sign in to comment.