From 9d8889a4924a1883c263f6766ba0e8e6393aa2a2 Mon Sep 17 00:00:00 2001 From: Arik Chakma Date: Mon, 3 Apr 2023 03:13:19 +0600 Subject: [PATCH] fix: de-structure error --- src/components/Setting/UpdateProfileForm.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/components/Setting/UpdateProfileForm.tsx b/src/components/Setting/UpdateProfileForm.tsx index 9ec427b56..1b93b29f6 100644 --- a/src/components/Setting/UpdateProfileForm.tsx +++ b/src/components/Setting/UpdateProfileForm.tsx @@ -49,10 +49,12 @@ export default function UpdateProfileForm() { setIsLoading(false); setName(data.name); setEmail(data.email); - const { github, linkedin, website } = data.links; - setGithub(github); - setLinkedin(linkedin); - setWebsite(website); + if (data.links) { + const { github, linkedin, website } = data.links; + setGithub(github || ''); + setLinkedin(linkedin || ''); + setWebsite(website || ''); + } setMessage({ type: 'success', message: 'Profile updated successfully', @@ -95,9 +97,9 @@ export default function UpdateProfileForm() { if (json.links) { const { github, linkedin, website } = json.links; - setGithub(github); - setLinkedin(linkedin); - setWebsite(website); + setGithub(github || ''); + setLinkedin(linkedin || ''); + setWebsite(website || ''); } } else { throw new Error(json.message);