mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
20 lines
596 B
JavaScript
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 };
|
||
|
}
|