Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brickpop/use-url-hash
A React hook to provide the upddated hash of the current URL
https://github.com/brickpop/use-url-hash
Last synced: 11 days ago
JSON representation
A React hook to provide the upddated hash of the current URL
- Host: GitHub
- URL: https://github.com/brickpop/use-url-hash
- Owner: brickpop
- Created: 2021-01-29T16:44:46.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-02-13T16:30:29.000Z (11 months ago)
- Last Synced: 2024-11-18T17:59:03.245Z (about 1 month ago)
- Language: TypeScript
- Size: 342 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Use URL Hash
A simple React hook providing the current URL hash and triggering a re-render on every change.
## Get started
Install the package:
```bash
npm i use-url-hash
```Import it in your component:
```tsx
import React from 'react'
import { useUrlHash } from "use-url-hash"const MyApp = () => {
const hash = useUrlHash()return (
Use URL Hash
The current URL hash is
"{hash}"
)
}
```The value of `hash` will be already set at the very first render.
## Example
Check out `example/index.tsx` for a working example.
```bash
cd example
npm install
npm start
```