Skip to content

Commit

Permalink
hotfix: revert usePrevious hook to fix rerender loop in governance fi…
Browse files Browse the repository at this point in the history
…dget
  • Loading branch information
nounspaceryan committed Jul 4, 2024
1 parent 307f1bd commit 66f4029
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/common/lib/hooks/usePrevious.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { useState } from "react";
import { useEffect, useRef } from "react";

export const usePrevious = (value: any) => {
const [current, setCurrent] = useState(value);
const [previous, setPrevious] = useState(null);

if (value !== current) {
setPrevious(current);
setCurrent(value);
}

return previous;
const ref = useRef();
useEffect(() => {
ref.current = value;
}, [value]);
return ref.current;
};

export default usePrevious;

0 comments on commit 66f4029

Please sign in to comment.