These files are provided as-is. Can't guarantee it works, but please comment with any fixes if it doesn't work correctly.
Using immer
is total overkill, I just had it there (I made this years ago). Feel free to remove that if you know what you're doing.
Add the provider to the root of your app (_app.tsx
).
Then, import the useCanGoBack
hook anywhere:
export function Screen() {
const getCanGoBack = useCanGoBack()
const showHeader = getCanGoBack()
if (showHeader) return <Header />
return null
}