Skip to content

Commit ae34f0d

Browse files
authored
Merge pull request #45 from IKIGUYZ/master
Fix bug crash when add new contract
2 parents 8734e91 + ef6d36d commit ae34f0d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/app/features/main/Main.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,16 @@ const Main = () => {
4343
const { selectedContract: contract, overwriteContract } =
4444
Contracts.useContainer();
4545
useQueryStringContract();
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-
}
46+
47+
useEffect(() => {
48+
const contracts = localStorage.getItem("contracts");
49+
if (!contracts) {
50+
return;
51+
}
52+
const result = `{"data":${contracts}}`;
53+
let jsonResult = JSON.parse(result).data;
54+
overwriteContract(jsonResult);
55+
}, []);
5456

5557
return (
5658
<Container>

0 commit comments

Comments
 (0)