K

use-hash

Get and set hash value in url
Import

Usage

Hook lets you get hash from url, subscribe to its changes with hashchange event and set it:

import { useHash, randomId } from '@mantine/hooks';
import { Button } from '@mantine/core';
export function Demo() {
const [hash, setHash] = useHash();
return <Button onClick={() => setHash(randomId())}>Set hash to random string</Button>
}

Definition

function useHash(): readonly [string, (value: string) => void];
Build fully functional accessible web applications with ease
Feedback
Your feedback is most valuable contribution to the project, please share how you use Mantine, what features are missing and what is done good
Leave feedback