Skip to content

Any reason for why window.history.state._depth doesn't get updated when clicking on <A/>? #529

Answered by Axedyson
Axedyson asked this question in Q&A
Discussion options

You must be logged in to vote

Okay I solved it by listening for window.history.state._depth this way 😎:

  const navigate = useNavigate();
  const isRouting = useIsRouting();
  const histDepth = createMemo(() => {
    // Subscribe to any route change. This should be able to handle the case 
    // where <A ... replace=True>...</A> by ignoring subscribers to this memo 
    // because window.history.state._depth will be the same as before.
    isRouting();
    return window.history.state._depth;
  });

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Axedyson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant