Last active
November 9, 2022 14:39
-
-
Save dmorenogogoleva/4a503a539ae94c5f4acc5547ca791adc to your computer and use it in GitHub Desktop.
Revisions
-
Daria Moreno-Gogoleva revised this gist
Nov 9, 2022 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,12 +4,12 @@ export function usePreviousPersistent<T extends unknown>(value: T) { prev: null, }); const currentValue = ref.current.value; if (!isEqual(value, currentValue)) { ref.current = { value, prev: currentValue, }; } -
Daria Moreno-Gogoleva revised this gist
Nov 9, 2022 . 1 changed file with 6 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,19 +1,17 @@ export function usePreviousPersistent<T extends unknown>(value: T) { const ref = useRef<{ value: T; prev: T | null }>({ value, prev: null, }); const current = ref.current.value; if (!isEqual(value, current)) { ref.current = { value, prev: current, }; } return ref.current.prev; } -
Daria Moreno-Gogoleva renamed this gist
Nov 9, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Daria Moreno-Gogoleva revised this gist
Nov 9, 2022 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ export function usePreviousPersistent<T extends unknown>( value: TValue ) { const ref = useRef<{ value: T; prev: T | null }>({ value: value, prev: null -
Daria Moreno-Gogoleva created this gist
Nov 9, 2022 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ export const usePreviousPersistent = <T extends unknown>( value: TValue ) => { const ref = useRef<{ value: T; prev: T | null }>({ value: value, prev: null }); const current = ref.current.value; if (!isEqual(value, current)) { ref.current = { value: value, prev: current }; } return ref.current.prev; };