1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-05-01 23:56:41 +07:00

made transitional Anchor component for next/cra

This commit is contained in:
Fedor Katurov 2022-01-13 16:08:23 +07:00
parent 7658068caa
commit 14b93d5dbb
7 changed files with 44 additions and 18 deletions

View file

@ -0,0 +1,22 @@
import { useCallback } from 'react';
import { CONFIG } from '~/utils/config';
import { useRouter } from 'next/router';
import { useHistory } from 'react-router';
export const useNavigation = () => {
const nextRouter = useRouter();
const craHistory = useHistory();
const push = useCallback(
(url: string) => {
if (CONFIG.isNextEnvironment) {
nextRouter.push(url);
} else {
craHistory.push(url);
}
},
[craHistory, nextRouter]
);
return { push };
};