From ac51e14ba99486db5497adb4849486ed605d981b Mon Sep 17 00:00:00 2001 From: Nick Koukis Date: Sat, 14 Oct 2023 01:01:18 +0300 Subject: [PATCH] test json data --- .../components/NewUserForm/ViewWallet.tsx | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/views/Home/components/NewUserForm/ViewWallet.tsx b/src/views/Home/components/NewUserForm/ViewWallet.tsx index 50bb511..11db20a 100644 --- a/src/views/Home/components/NewUserForm/ViewWallet.tsx +++ b/src/views/Home/components/NewUserForm/ViewWallet.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; - +import { useEffect } from 'react'; interface UserInfo { address: string; secretWords: string[]; @@ -14,16 +14,16 @@ interface ViewWalletProps { const ViewWallet: React.FC = ({ userInfo, isLoadingUserInfo, jsonPrettyData }) => { const [parsedData, setParsedData] = useState(null); - if (jsonPrettyData !== '') { - setParsedData(JSON.parse(jsonPrettyData)); - } + useEffect(() => { + if (jsonPrettyData !== '') { + setParsedData(JSON.parse(jsonPrettyData)); + } + }, [jsonPrettyData]); const handleDownload = () => { if (parsedData) { const jsonContent = JSON.stringify(parsedData, null, 2); - const blob = new Blob([jsonContent], { type: 'application/json' }); - const url = window.URL.createObjectURL(blob); const a = document.createElement('a'); @@ -31,7 +31,6 @@ const ViewWallet: React.FC = ({ userInfo, isLoadingUserInfo, js a.download = 'file.json'; a.click(); - window.URL.revokeObjectURL(url); } }; @@ -44,7 +43,7 @@ const ViewWallet: React.FC = ({ userInfo, isLoadingUserInfo, js

View Wallet

Address: {userInfo.address}

- {parsedData !== '' && ( + {parsedData !== null && (
@@ -53,6 +52,4 @@ const ViewWallet: React.FC = ({ userInfo, isLoadingUserInfo, js )}
); -}; - -export default ViewWallet; +}; \ No newline at end of file