Skip to content

Commit 895f6d3

Browse files
committed
fix localStorage build
1 parent 8a509da commit 895f6d3

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

components/Body/NotificationBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import axios from "axios";
1616
const CLOSED_KEY = "new-ui-notif-closed";
1717

1818
function NotificationBar() {
19-
const isClosed = localStorage.getItem(CLOSED_KEY);
19+
// const isClosed = localStorage.getItem(CLOSED_KEY);
2020

2121
// const [isVisible, setIsVisible] = useState(
2222
// isClosed === "true" ? false : true

components/Body/index.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,23 @@ const allNetworksOptions = [
6666

6767
function Body() {
6868
let addressFromURL: string | null = null;
69+
let showAddressCache: string | null = null;
6970
let urlFromURL: string | null = null;
7071
let urlFromCache: string | null = null;
7172
let chainFromURL: string | null = null;
73+
let tenderlyForkIdCache: string | null = null;
7274

7375
if (typeof window !== "undefined") {
7476
const urlParams = new URLSearchParams(window.location.search);
7577
addressFromURL = urlParams.get("address");
7678
urlFromURL = urlParams.get("url");
77-
urlFromCache = localStorage.getItem("appUrl");
7879
chainFromURL = urlParams.get("chain");
7980
}
81+
if (typeof localStorage !== "undefined") {
82+
showAddressCache = localStorage.getItem("showAddress");
83+
urlFromCache = localStorage.getItem("appUrl");
84+
tenderlyForkIdCache = localStorage.getItem("tenderlyForkId");
85+
}
8086
let networkIdViaURL = 1;
8187
if (chainFromURL) {
8288
for (let i = 0; i < allNetworksOptions.length; i++) {
@@ -103,10 +109,10 @@ function Body() {
103109

104110
const [provider, setProvider] = useState<ethers.providers.JsonRpcProvider>();
105111
const [showAddress, setShowAddress] = useState(
106-
addressFromURL ?? localStorage.getItem("showAddress") ?? ""
112+
addressFromURL ?? showAddressCache ?? ""
107113
); // gets displayed in input. ENS name remains as it is
108114
const [address, setAddress] = useState(
109-
addressFromURL ?? localStorage.getItem("showAddress") ?? ""
115+
addressFromURL ?? showAddressCache ?? ""
110116
); // internal resolved address
111117
const [isAddressValid, setIsAddressValid] = useState(true);
112118
const [uri, setUri] = useState("");
@@ -133,7 +139,7 @@ function Body() {
133139
const [iframeKey, setIframeKey] = useState(0); // hacky way to reload iframe when key changes
134140

135141
const [tenderlyForkId, setTenderlyForkId] = useState(
136-
localStorage.getItem("tenderlyForkId") ?? ""
142+
tenderlyForkIdCache ?? ""
137143
);
138144
const [sendTxnData, setSendTxnData] = useState<TxnDataType[]>([]);
139145

0 commit comments

Comments
 (0)