Skip to content

Commit

Permalink
reload on address page
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonmanRolls committed Jan 25, 2024
1 parent f8ab0d3 commit 66565d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import EnteryourDelegate from "./pages/EnteryourDelegate";
import Home from "./pages/Home";
import { useGetDelegates, useQueryString } from "./utils/hooks";
import { initWeb3Read, rpcUrl } from "./web3modal";
import { usePrevious } from "react-use";

const PROJECT_ID = "02f438d1701ea8029113972850066224";

Expand Down Expand Up @@ -146,14 +147,19 @@ function ConnectedRoute({ component: Component, ...rest }) {

function App() {
const query = useQueryString();
const { address, isConnected } = useWeb3ModalAccount();
const { address } = useWeb3ModalAccount();
const previousAddress = usePrevious(address);

useEffect(() => {
const delegate = query.get("delegate");
if (delegate && address) {
setDelegateChoice(address, delegate);
setDelegateReferral(delegate);
}

if (previousAddress && address && previousAddress !== address) {
window.location.reload();
}
}, [address]);

return (
Expand Down
2 changes: 1 addition & 1 deletion src/utils/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { normalize } from "@ensdomains/eth-ens-namehash";
import { Contract, ethers } from "ethers";
import { gql } from "graphql-tag";
import { keccak_256 as sha3 } from "js-sha3";
import { useEffect, useState } from "react";
import { useEffect, useRef, useState } from "react";
import { useLocation } from "react-router-dom";
import {
apolloClientInstance,
Expand Down

0 comments on commit 66565d1

Please sign in to comment.