Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | const scrollToElement = (history: { push: (path:string) => void; }, id: string, event?: { preventDefault: () => void; }): void => { //Replaces anchor for React console.log("Scrolled to " + id) event?.preventDefault(); if (id) { const element = document.getElementById(id) element?.scrollIntoView() } }; const redirect = (history:{ push: (path:string) => void; } , path: string, event?: { preventDefault: () => void; }): void => { console.log("Redirected to " + path) event?.preventDefault(); if (path !== window.location.pathname) history.push(path); }; export {redirect, scrollToElement} |