From ec0762981e77a7ae37dd2f3e6e0d8b11a01e4f2c Mon Sep 17 00:00:00 2001 From: Leon Date: Wed, 13 Oct 2021 22:51:35 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=ED=8C=8C=EC=8B=B1=20=EC=97=90=EB=9F=AC?= =?UTF-8?q?=20=ED=95=B4=EA=B2=B0=20=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index.tsx | 15 +++++++++++---- src/views/MyPage/Guide/Guide.tsx | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pages/index.tsx b/pages/index.tsx index 963d071..2bc0048 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -5,7 +5,10 @@ import { AndroidToast } from '@utils/android'; import { fetchNotifications } from '@api/api-notifications'; export default function MainPage() { - const [version, setVersion] = useState(''); + const [version, setVersion] = useState<{ prev: any; parsed: any }>({ + prev: '', + parsed: '', + }); const navList = [ { title: '메인', path: '/main' }, { title: 'QR코드', path: '/qrcode' }, @@ -46,13 +49,17 @@ export default function MainPage() { const version = (window as any).Android?.getVersionInfo() || `{"current_version": "sample"}`; - console.log(version); - setVersion(JSON.parse(version)?.current_version); + setVersion({ + prev: version, + parsed: JSON.parse(version)?.current_version, + }); }} style={{ marginBottom: 8, display: 'block' }} /> -
버전정보 : {version}
+
버전정보
+

파싱 전 : {version.prev}

+

파싱 후 : {version.parsed}

); diff --git a/src/views/MyPage/Guide/Guide.tsx b/src/views/MyPage/Guide/Guide.tsx index 68c440a..0b6d07a 100644 --- a/src/views/MyPage/Guide/Guide.tsx +++ b/src/views/MyPage/Guide/Guide.tsx @@ -12,7 +12,7 @@ const Guide = () => { const Android = (window as any)?.Android; const version = Android?.getVersionInfo() || `{"current_version": "-"}`; - setVersion(JSON.parse(version).current_version); + setVersion(JSON.parse(version)?.current_version); }, []); return (