mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-12 23:40:26 +00:00
17 lines
544 B
JavaScript
17 lines
544 B
JavaScript
const React = require('react');
|
|
|
|
const useLocationHash = () => {
|
|
const [locationHash, setLocationHash] = React.useState(window.location.hash);
|
|
const onLocationHashChanged = React.useCallback(() => {
|
|
setLocationHash(window.location.hash);
|
|
}, []);
|
|
useEffect(() => {
|
|
window.addEventListener('hashchange', onLocationHashChanged);
|
|
return () => {
|
|
window.removeEventListener('hashchange', onLocationHashChanged);
|
|
};
|
|
}, []);
|
|
return locationHash;
|
|
};
|
|
|
|
module.exports = useLocationHash;
|