Skip to content

Commit cd395ef

Browse files
authored
Fix loading up when contracts are undefined
1 parent ca7cd26 commit cd395ef

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src/app/features/main/Main.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,15 @@ const Main = () => {
4343
const { selectedContract: contract, overwriteContract } =
4444
Contracts.useContainer();
4545
useQueryStringContract();
46-
useEffect(() => {
47-
let result = localStorage.getItem("contracts");
48-
result = `{"data":${result}}`;
49-
let jsonResult = JSON.parse(result).data;
50-
overwriteContract(jsonResult);
51-
}, [contract]);
46+
if (localStorage.getItem("contracts")) {
47+
useEffect(() => {
48+
let result = localStorage.getItem("contracts");
49+
result = `{"data":${result}}`;
50+
let jsonResult = JSON.parse(result).data;
51+
overwriteContract(jsonResult);
52+
}, [contract]);
53+
}
54+
5255
return (
5356
<Container>
5457
<ContentFrame label={contract && contract.name}>

0 commit comments

Comments
 (0)