-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from AudiusProject/jowlee-hash-router
Hash Routing
- Loading branch information
Showing
4 changed files
with
31 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { useEffect } from 'react' | ||
import { useLocation } from 'react-router-dom' | ||
|
||
/** | ||
* NOTE: updated the route from the legacy url structure to hash routing. | ||
* ie. /services/service-providers => /#/services/service-providers | ||
* | ||
* NOTE: When switching to being served from ipfs, this needs to be updated for the | ||
* client to be loaded via ipns | ||
*/ | ||
|
||
// -------------------------------- Hooks -------------------------------- | ||
export const useRerouteLegacy = () => { | ||
const location = useLocation() | ||
useEffect(() => { | ||
if (window.location.pathname !== '/') { | ||
window.history.replaceState({}, '', `/#${window.location.pathname}`) | ||
} | ||
}, [location]) | ||
} | ||
|
||
export default useRerouteLegacy |