Skip to content

Latest commit

 

History

History
16 lines (12 loc) · 524 Bytes

File metadata and controls

16 lines (12 loc) · 524 Bytes

The useRoute hook

The useRoute hook is a very simple React hook that gets the current window.location.href, splits it up, and returns:

type {
  hash: string
  path: Array<string>
  route: URL
}

More importantly, it sets an HTML event listener to listen for hashchange events, and whenever the hash changes, it updates the route output.

This is used for hash-based routing in this application.