-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add condition to display back button #356
base: develop
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -103,6 +103,7 @@ function DonationInfo() { | |||
} = React.useContext(QueryParamContext); | |||
|
|||
const [isMobile, setIsMobile] = React.useState(false); | |||
const [showBackButton, setShowBackButton] = React.useState(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use boolean state as for isMobile
above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because I if the value if set to false at any point of time, it means that the user came from an external link and so I don't want to display the back button. Setting false initially would prevent me from updating the value and setting true would display the back button. Hence, I've set null as the initial value.
storage.setItem("currentPath", window.origin); | ||
} | ||
|
||
useEffect(storePathValues, [router]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not put the code of the function directly into the useEffect(() => {...}, [router]);
instead of defining a new function storePathValues
?
if (!storage) return; | ||
// Set the previous path as the value of the current path. | ||
const prevPath = storage.getItem("currentPath"); | ||
storage.setItem("prevPath", prevPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This raises a warning about a type error for string | null
.
const isShow = storage.getItem("showBackButton") === "true"; | ||
|
||
setShowBackButton(isShow); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be just one line of code.
when I tried to visit from webapp to donation using donate button in the webapp , The back button was not visible for me |
Checked this, when I have originally no callback_url and click on the back arrow from the contact details, then I also see the back button, that should be not visible in this case. |
Changes in this pull request:
=====================
@