1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-25 11:28:51 +01:00
metamask-extension/ui/hooks/useRouting.js

20 lines
596 B
JavaScript
Raw Normal View History

2023-02-01 06:54:18 +01:00
import { useCallback } from 'react';
import { useHistory } from 'react-router-dom';
import { useSelector } from 'react-redux';
import { getMostRecentOverviewPage } from '../ducks/history/history';
/**
* useRouting - hook for re-uable reoting related code.
*/
export function useRouting() {
const history = useHistory();
const mostRecentOverviewPage = useSelector(getMostRecentOverviewPage);
const navigateToMostRecentOverviewPage = useCallback(() => {
history.push(mostRecentOverviewPage);
}, [history, mostRecentOverviewPage]);
return { navigateToMostRecentOverviewPage };
}