mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-26 04:57:50 +02:00
fix(theme-common): useLocationChange fire un-necessarily twice (#6070)
This commit is contained in:
parent
3394f7e91f
commit
f5a404b877
1 changed files with 6 additions and 4 deletions
|
@ -25,9 +25,11 @@ export function useLocationChange(onLocationChange: OnLocationChange): void {
|
||||||
const onLocationChangeDynamic = useDynamicCallback(onLocationChange);
|
const onLocationChangeDynamic = useDynamicCallback(onLocationChange);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onLocationChangeDynamic({
|
if (location !== previousLocation) {
|
||||||
location,
|
onLocationChangeDynamic({
|
||||||
previousLocation,
|
location,
|
||||||
});
|
previousLocation,
|
||||||
|
});
|
||||||
|
}
|
||||||
}, [onLocationChangeDynamic, location, previousLocation]);
|
}, [onLocationChangeDynamic, location, previousLocation]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue