-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No back button #9
Comments
Does it work fine for you now? |
No. |
It`s maybe a wrong way but I added the BackButton this way: src\components\Root\Root.tsx import {initBackButton} from "@telegram-apps/sdk-react";
import { usePathname, useRouter } from "next/navigation"; ... function App(props: PropsWithChildren) {
const [backbutton] = initBackButton();
const { back } = useRouter();
const pathname = usePathname();
const onBackClick = useCallback(() => {
if (pathname !== "/") {
back();
}
}, [back, pathname]);
useEffect(() => {
backbutton.on("click", onBackClick);
return () => {
backbutton.off("click", onBackClick);
};
}, [backbutton, onBackClick]);
useEffect(() => {
if (pathname !== "/") {
backbutton.show();
} else {
backbutton.hide();
}
}, [backbutton, pathname])
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the latest version with App Router there is no back button after routing. In previous versions with Pages Router (for example, 39c4e4f) this button exists and works correctly. This also works for https://github.com/Telegram-Mini-Apps/reactjs-template.
The text was updated successfully, but these errors were encountered: