Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
@mantine/hooks
Advanced tools
[![npm](https://img.shields.io/npm/dm/@mantine/hooks)](https://www.npmjs.com/package/@mantine/hooks)
@mantine/hooks is a collection of React hooks that provide a wide range of functionalities to simplify state management, UI interactions, and other common tasks in React applications.
useLocalStorage
The `useLocalStorage` hook allows you to easily manage state that is synchronized with localStorage. This is useful for persisting user preferences or other data that should be retained across page reloads.
import { useLocalStorage } from '@mantine/hooks';
function Demo() {
const [value, setValue] = useLocalStorage({ key: 'my-key', defaultValue: 'default' });
return (
<div>
<input value={value} onChange={(event) => setValue(event.currentTarget.value)} />
<p>Stored value: {value}</p>
</div>
);
}
useDebouncedValue
The `useDebouncedValue` hook helps to manage a debounced state value. This is particularly useful for scenarios like search input where you want to delay the execution of a function until the user has stopped typing.
import { useDebouncedValue } from '@mantine/hooks';
import { useState } from 'react';
function Demo() {
const [value, setValue] = useState('');
const [debouncedValue] = useDebouncedValue(value, 200);
return (
<div>
<input value={value} onChange={(event) => setValue(event.currentTarget.value)} />
<p>Debounced value: {debouncedValue}</p>
</div>
);
}
useClickOutside
The `useClickOutside` hook allows you to detect clicks outside of a specified element. This is useful for closing dropdowns, modals, or other pop-up elements when the user clicks outside of them.
import { useClickOutside } from '@mantine/hooks';
import { useRef, useState } from 'react';
function Demo() {
const [opened, setOpened] = useState(false);
const ref = useRef();
useClickOutside(ref, () => setOpened(false));
return (
<div>
<button onClick={() => setOpened((o) => !o)}>Toggle dropdown</button>
{opened && (
<div ref={ref}>
<p>Click outside this element to close it</p>
</div>
)}
</div>
);
}
react-use is a collection of essential React hooks that cover a wide range of use cases, from state management to side effects and UI interactions. It is similar to @mantine/hooks in terms of the breadth of hooks provided, but it has a larger community and more extensive documentation.
ahooks is a React hooks library that provides a comprehensive set of high-quality hooks. It is similar to @mantine/hooks in that it aims to simplify common tasks in React development, but it also includes some unique hooks and utilities not found in @mantine/hooks.
usehooks-ts is a collection of React hooks written in TypeScript. It offers a similar range of hooks as @mantine/hooks but is specifically designed for TypeScript users, providing type-safe hooks out of the box.
A set of react hooks for state and UI management
# With yarn
yarn add @mantine/hooks
# With npm
npm install @mantine/hooks
MIT
FAQs
A collection of 50+ hooks for state and UI management
The npm package @mantine/hooks receives a total of 465,284 weekly downloads. As such, @mantine/hooks popularity was classified as popular.
We found that @mantine/hooks demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.