import {router} from 'expo-router'

// go back, or land on home when the stack has nowhere to return to — a deep
// link or cold start straight into a nested screen leaves no history, so a
// bare back() would dead-end in a no-op. use everywhere instead of
// router.back() so a back action always resolves to somewhere
export const goBack = (): void => {
  if (router.canGoBack()) router.back()
  else router.replace('/')
}
