How do you typically determine if user is navigating from within your website? #32725
Unanswered
michaeljblum
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I understand Gatsby is essentially using reach/router for routing etc. With this in mind, it makes sense that you might go about determining if a user is navigating from within your website by doing something like the following: use location.state that you set with the state property on the Link component to set, say, a fromWithin state to true on every time you navigate to home page from within your website, and then read the location prop in your home page - if fromWithin is true, then you've navigated from within website, if not, you haven't.
The one problem with this is that whenever you refresh your home page, from some reason reach/router's location is retained as long as you haven't physically navigated to a different website (reach might just be using the window's location? either way). Should I bother figuring out how to clear reach/the window's location.state on page refresh to get around this problem, or is there a more suitable way of accomplishing the problem asked in the subject header?
Beta Was this translation helpful? Give feedback.
All reactions