Skip to content

Instantly share code, notes, and snippets.

@sibelius
Created July 19, 2019 15:21
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sibelius/ca8f3d2d1ba95dac23df52c2e3070f7b to your computer and use it in GitHub Desktop.
Save sibelius/ca8f3d2d1ba95dac23df52c2e3070f7b to your computer and use it in GitHub Desktop.
Safe goBack helper to avoid leaving the site
export const safeGoBack = (
history: History,
alternativeRoute: string,
) => {
if (history.length > 2) {
history.goBack();
return;
}
history.push(alternativeRoute);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment