File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
src/components/sections/homepage/_partials/testimonials Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 1
1
import Button from "@/components/ui/button" ;
2
2
import DiscordIcon from "@/icons/discord.svg" ;
3
3
import { useTranslation } from "next-i18next" ;
4
+ import { useMemo } from "react" ;
4
5
5
6
/**
6
7
* Statistic interface definitions
@@ -33,15 +34,24 @@ const stats: Statistic[] = [
33
34
] ;
34
35
export default function CommunityStats ( ) {
35
36
const { t } = useTranslation ( ) ;
36
- const digitFormatter = new Intl . NumberFormat ( ) ;
37
+ const digitFormatter = useMemo ( ( ) => new Intl . NumberFormat ( ) , [ ] ) ;
38
+
39
+ const formattedStat = useMemo (
40
+ ( ) =>
41
+ stats . map ( ( stat : Statistic ) => ( {
42
+ ...stat ,
43
+ count : digitFormatter . format ( stat . count ) ,
44
+ } ) ) ,
45
+ [ digitFormatter ]
46
+ ) ;
37
47
38
48
return (
39
49
< div className = "p-7 bg-primary rounded-3.5xl mx-auto text-white relative md:absolute md:top-28 lg:top-32 xl:w-1/3 md:w-4/6 z-10 sm:max-w-sm" >
40
50
< h3 className = "m-0 text-4.5xl w-3/4" > { t ( "testimonials.community.title" ) } </ h3 >
41
51
< div className = "relative divide-y divide-white divide-dotted" >
42
- { stats . map ( ( stat ) => (
52
+ { formattedStat . map ( ( stat ) => (
43
53
< div key = { stat . title } className = "py-6" >
44
- < span className = "block text-.5xl mb-2" > { digitFormatter . format ( stat . count ) } </ span >
54
+ < span className = "block text-.5xl mb-2" > { stat . count } </ span >
45
55
< p className = "text-base w-3/4 m-0" >
46
56
< span className = "font-graphik font-medium" > { t ( stat . title ) } </ span > { t ( stat . description ) }
47
57
</ p >
You can’t perform that action at this time.
0 commit comments