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