mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-30 02:30:57 +00:00
17 lines
536 B
JavaScript
17 lines
536 B
JavaScript
const React = require('react');
|
|
|
|
const useLocationHash = () => {
|
|
const [locationHash, setLocationHash] = React.useState(window.location.hash);
|
|
React.useEffect(() => {
|
|
const onLocationHashChange = () => {
|
|
setLocationHash(window.location.hash);
|
|
};
|
|
window.addEventListener('hashchange', onLocationHashChange);
|
|
return () => {
|
|
window.removeEventListener('hashchange', onLocationHashChange);
|
|
};
|
|
}, []);
|
|
return locationHash;
|
|
};
|
|
|
|
module.exports = useLocationHash;
|