fix(v2): ignore hash changes in useChangeRoute hook (#5023)

* fix(v2): ignore hash changes in useChangeRoute hook

* refactor and introduce useLocationChange hook

Co-authored-by: slorber <lorber.sebastien@gmail.com>
This commit is contained in:
Alexey Pyltsyn 2021-06-22 13:41:58 +03:00 committed by GitHub
parent 41eaa690ee
commit 8bda3b2dbf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 73 additions and 37 deletions

View file

@ -0,0 +1,18 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import {useRef, useEffect} from 'react';
export function usePrevious<T>(value: T): T | undefined {
const ref = useRef<T>();
useEffect(() => {
ref.current = value;
});
return ref.current;
}