How to check if it's possible to go back - TanStack