Skip to content

Commit

Permalink
fix: 파싱 에러 해결 중
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-dunamu committed Oct 13, 2021
1 parent d279bfa commit ec07629
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import { AndroidToast } from '@utils/android';
import { fetchNotifications } from '@api/api-notifications';

export default function MainPage() {
const [version, setVersion] = useState<string>('');
const [version, setVersion] = useState<{ prev: any; parsed: any }>({
prev: '',
parsed: '',
});
const navList = [
{ title: '메인', path: '/main' },
{ title: 'QR코드', path: '/qrcode' },
Expand Down Expand Up @@ -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' }}
/>
<h5>버전정보 : {version}</h5>
<h5>버전정보</h5>
<p>파싱 전 : {version.prev}</p>
<p>파싱 후 : {version.parsed}</p>
</div>
</>
);
Expand Down
2 changes: 1 addition & 1 deletion src/views/MyPage/Guide/Guide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit ec07629

Please sign in to comment.