1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-24 19:10:22 +01:00
metamask-extension/ui/hooks/useRouting.js
2023-02-01 11:24:18 +05:30

20 lines
596 B
JavaScript

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 };
}