From d1ec67d0217b1246555d354ff130745f12e45c22 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Wed, 28 Dec 2022 23:39:54 -0800 Subject: [PATCH] Fix null element on GridRep --- components/GridRep/index.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/GridRep/index.tsx b/components/GridRep/index.tsx index f1b2c6af..d58034f7 100644 --- a/components/GridRep/index.tsx +++ b/components/GridRep/index.tsx @@ -81,8 +81,12 @@ const GridRep = (props: Props) => { let url = '' if (mainhand) { - if (mainhand.element == 0 && props.grid[0] && props.grid[0].element) { - url = `${process.env.NEXT_PUBLIC_SIERO_IMG_URL}/weapon-main/${mainhand.granblue_id}_${props.grid[0].element}.jpg` + const weapon = Object.values(props.grid).find( + (w) => w && w.object.id === mainhand.id + ) + + if (mainhand.element == 0 && weapon && weapon.element) { + url = `${process.env.NEXT_PUBLIC_SIERO_IMG_URL}/weapon-main/${mainhand.granblue_id}_${weapon.element}.jpg` } else { url = `${process.env.NEXT_PUBLIC_SIERO_IMG_URL}/weapon-main/${mainhand.granblue_id}.jpg` }