-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1298 from chainapsis/Thunnini/KEPLR-727
ibc transfer에서 기본 send로 변할때 recipient를 초기화하도록 수정
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { useRef } from "react"; | ||
|
||
export type Predicate<T> = (prev: T | undefined, next: T) => boolean; | ||
|
||
const strictEquals = <T>(prev: T | undefined, next: T) => prev === next; | ||
|
||
const useFirstMountState = (): boolean => { | ||
const isFirst = useRef(true); | ||
|
||
if (isFirst.current) { | ||
isFirst.current = false; | ||
|
||
return true; | ||
} | ||
|
||
return isFirst.current; | ||
}; | ||
|
||
export const usePreviousDistinct = <T>( | ||
value: T, | ||
compare: Predicate<T> = strictEquals | ||
): T | undefined => { | ||
const prevRef = useRef<T>(); | ||
const curRef = useRef<T>(value); | ||
const isFirstMount = useFirstMountState(); | ||
|
||
if (!isFirstMount && !compare(curRef.current, value)) { | ||
prevRef.current = curRef.current; | ||
curRef.current = value; | ||
} | ||
|
||
return prevRef.current; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters