From 197c3531d2d7d5731e1725e6ff465b9f01aab7b5 Mon Sep 17 00:00:00 2001 From: ponchimeow Date: Fri, 7 Jan 2022 12:56:59 +0800 Subject: [PATCH 1/2] [BUGFIX] add ternary operator --- src/hooks/member.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/member.ts b/src/hooks/member.ts index 12f551d2f..ea383c214 100644 --- a/src/hooks/member.ts +++ b/src/hooks/member.ts @@ -520,7 +520,7 @@ export const useMemberNotesAdmin = ( return { ...prev, member_note_aggregate: fetchMoreResult.member_note_aggregate, - member_note: [...prev.member_note, ...fetchMoreResult.member_note], + member_note: [...(prev ? prev.member_note : []), ...fetchMoreResult.member_note], } }, }) From ebdd0dd69c0553a19a4dd778311e0dc282a4c28f Mon Sep 17 00:00:00 2001 From: ponchimeow Date: Fri, 7 Jan 2022 17:18:18 +0800 Subject: [PATCH 2/2] [REFACTOR] make code readable --- src/hooks/member.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hooks/member.ts b/src/hooks/member.ts index ea383c214..e458fb581 100644 --- a/src/hooks/member.ts +++ b/src/hooks/member.ts @@ -517,10 +517,11 @@ export const useMemberNotesAdmin = ( if (!fetchMoreResult) { return prev } + const result = prev ? prev.member_note : [] return { ...prev, member_note_aggregate: fetchMoreResult.member_note_aggregate, - member_note: [...(prev ? prev.member_note : []), ...fetchMoreResult.member_note], + member_note: [...result, ...fetchMoreResult.member_note], } }, })