Skip to content

Commit df6f53e

Browse files
committed
fix: empty bento box on load
refactor useBentoBox as data without useState
1 parent 7b726b6 commit df6f53e

File tree

2 files changed

+47
-55
lines changed

2 files changed

+47
-55
lines changed

src/components/Homepage/useBentoBox.ts

Lines changed: 46 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import { useEffect, useState } from "react"
21
import { useTranslation } from "next-i18next"
32

43
import { cn } from "@/lib/utils/cn"
54

6-
import type { BentoCardProps } from "./BentoCard"
7-
85
import ImpactImage from "@/public/images/impact_transparent.png"
96
import ManAndDogImage from "@/public/images/man-and-dog-playing.png"
107
import ManBabyWomanImage from "@/public/images/man-baby-woman.png"
@@ -90,56 +87,51 @@ const getPosition = (position: number): string =>
9087

9188
export const useBentoBox = () => {
9289
const { t } = useTranslation("page-index")
93-
const [items, setItems] = useState<BentoCardProps[]>([])
94-
95-
useEffect(() => {
96-
setItems([
97-
{
98-
title: t("page-index-bento-stablecoins-title"),
99-
children: t("page-index:page-index-bento-stablecoins-content"),
100-
action: t("page-index:page-index-bento-stablecoins-action"),
101-
href: "/stablecoins/",
102-
imgSrc: ImpactImage,
103-
imgWidth: 400,
104-
className: cn(colorOptions["primary"], getPosition(0)),
105-
},
106-
{
107-
title: t("page-index:page-index-bento-defi-title"),
108-
children: t("page-index:page-index-bento-defi-content"),
109-
action: t("page-index:page-index-bento-defi-action"),
110-
href: "/defi/",
111-
imgSrc: ManAndDogImage,
112-
className: cn(colorOptions["accent-c"], getPosition(1)),
113-
},
114-
{
115-
title: t("page-index:page-index-bento-dapps-title"),
116-
children: t("page-index:page-index-bento-dapps-content"),
117-
action: t("page-index:page-index-bento-dapps-action"),
118-
href: "/dapps/",
119-
imgSrc: MergeImage,
120-
imgWidth: 320,
121-
className: cn(colorOptions["accent-b"], getPosition(2)),
122-
},
123-
{
124-
title: t("page-index:page-index-bento-networks-title"),
125-
children: t("page-index:page-index-bento-networks-content"),
126-
action: t("page-index:page-index-bento-networks-action"),
127-
href: "/layer-2/",
128-
imgSrc: ManBabyWomanImage,
129-
imgWidth: 324,
130-
className: cn(colorOptions["accent-a"], getPosition(3)),
131-
},
132-
{
133-
title: t("page-index:page-index-bento-assets-title"),
134-
children: t("page-index:page-index-bento-assets-content"),
135-
action: t("page-index:page-index-bento-assets-action"),
136-
href: "/nft/",
137-
imgSrc: RobotBarImage,
138-
imgWidth: 324,
139-
className: cn(colorOptions["primary"], getPosition(4)),
140-
},
141-
])
142-
}, [t])
14390

144-
return { items }
91+
return [
92+
{
93+
title: t("page-index-bento-stablecoins-title"),
94+
children: t("page-index:page-index-bento-stablecoins-content"),
95+
action: t("page-index:page-index-bento-stablecoins-action"),
96+
href: "/stablecoins/",
97+
imgSrc: ImpactImage,
98+
imgWidth: 400,
99+
className: cn(colorOptions["primary"], getPosition(0)),
100+
},
101+
{
102+
title: t("page-index:page-index-bento-defi-title"),
103+
children: t("page-index:page-index-bento-defi-content"),
104+
action: t("page-index:page-index-bento-defi-action"),
105+
href: "/defi/",
106+
imgSrc: ManAndDogImage,
107+
className: cn(colorOptions["accent-c"], getPosition(1)),
108+
},
109+
{
110+
title: t("page-index:page-index-bento-dapps-title"),
111+
children: t("page-index:page-index-bento-dapps-content"),
112+
action: t("page-index:page-index-bento-dapps-action"),
113+
href: "/dapps/",
114+
imgSrc: MergeImage,
115+
imgWidth: 320,
116+
className: cn(colorOptions["accent-b"], getPosition(2)),
117+
},
118+
{
119+
title: t("page-index:page-index-bento-networks-title"),
120+
children: t("page-index:page-index-bento-networks-content"),
121+
action: t("page-index:page-index-bento-networks-action"),
122+
href: "/layer-2/",
123+
imgSrc: ManBabyWomanImage,
124+
imgWidth: 324,
125+
className: cn(colorOptions["accent-a"], getPosition(3)),
126+
},
127+
{
128+
title: t("page-index:page-index-bento-assets-title"),
129+
children: t("page-index:page-index-bento-assets-content"),
130+
action: t("page-index:page-index-bento-assets-action"),
131+
href: "/nft/",
132+
imgSrc: RobotBarImage,
133+
imgWidth: 324,
134+
className: cn(colorOptions["primary"], getPosition(4)),
135+
},
136+
]
145137
}

src/components/Homepage/useHome.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const useHome = () => {
3636
const [isModalOpen, setModalOpen] = useState(false)
3737
const [activeCode, setActiveCode] = useState(0)
3838

39-
const { items: bentoItems } = useBentoBox()
39+
const bentoItems = useBentoBox()
4040

4141
const toggleCodeExample = (id: number): void => {
4242
setActiveCode(id)

0 commit comments

Comments
 (0)