Skip to content

Commit

Permalink
feat: usenavigate function created
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikmv committed Jan 23, 2025
1 parent 4dc3ed0 commit b57a200
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/core_modules/capture-core/utils/routing/useNavigate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// @flow
import { useHistory } from 'react-router-dom';

export const useNavigate = () => {
const history = useHistory();

const navigate = (path: string, scrollToTop: boolean = true) =>
history
.push(path)
.then(() => {
if (scrollToTop) {
window.scrollTo(0, 0);
}
});

return { navigate };
};

0 comments on commit b57a200

Please sign in to comment.