Download wp-calypso/client/landing/stepper/hooks/use-hash.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 422 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/landing/stepper/hooks/use-hash.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/landing/stepper/hooks/use-hash.ts
-
curl -L -o use-hash.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/landing/stepper/hooks/use-hash.ts
422 Bytes
| import { useState, useEffect } from '@wordpress/element'; | |
| export function useHash() { | |
| const [ hash, setHash ] = useState( window.location.hash ); | |
| useEffect( () => { | |
| const handleHashChange = () => { | |
| setHash( window.location.hash ); | |
| }; | |
| window.addEventListener( 'hashchange', handleHashChange ); | |
| return () => { | |
| window.removeEventListener( 'hashchange', handleHashChange ); | |
| }; | |
| }, [] ); | |
| return hash; | |
| } | |