
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@gmana/react-hooks
Advanced tools
A comprehensive collection of production-ready React hooks for modern applications. Built with TypeScript and fully tested.
# npm
npm install @gmana/react-hooks
# yarn
yarn add @gmana/react-hooks
# pnpm
pnpm add @gmana/react-hooks
# bun
bun add @gmana/react-hooks
import React from "react"
import { useBoolean, useCounter, useFetch } from "@gmana/react-hooks"
function App() {
const { value: isVisible, toggle } = useBoolean(false)
const { count, increment, decrement } = useCounter(0)
const { data, error } = useFetch<{ title: string }>("https://api.example.com/data")
if (error) return <div>Error loading data</div>
if (!data) return <div>Loading...</div>
return (
<div>
<h1>{data.title}</h1>
<p>Count: {count}</p>
<button onClick={increment}>+</button>
<button onClick={decrement}>-</button>
<button onClick={toggle}>{isVisible ? "Hide" : "Show"} Content</button>
{isVisible && <div>Toggle content</div>}
</div>
)
}
useBoolean
- Manage boolean state with helper functionsuseCounter
- Counter with increment, decrement, and resetuseToggle
- Toggle between values with customizable statesuseToggleState
- Advanced toggle state managementuseArray
- Array manipulation with push, filter, remove operationsuseMap
- Map data structure with CRUD operationsuseStep
- Multi-step form/wizard state managementuseElementSize
- Track element dimensionsuseWindowSize
- Monitor window dimensionsuseDimensions
- Get container dimensionsuseHover
- Detect hover state on elementsuseInView
- Check if element is in viewportuseIntersectionObserver
- Advanced intersection observeruseOnClickOutside
- Detect clicks outside elementuseLockedBody
- Lock/unlock body scrolluseSidebar
- Sidebar state managementuseFetch
- HTTP requests with caching and error handlinguseNetworkInformation
- Network connection detailsuseOfflineDetector
- Online/offline status detectionuseLocalStorage
- Local storage with synchronizationuseReadLocalStorage
- Read-only local storage accessuseCookies
- Cookie management utilitiesuseMediaQuery
- CSS media query matchinguseMobile
- Mobile device detectionuseScreen
- Screen information accessuseClipboard
- Clipboard operationsuseCopyToClipboard
- Copy text to clipboarduseEstimateStorage
- Storage quota estimationuseScript
- Dynamic script loadinguseDebounce
- Debounce values and callbacksuseDebounceA
- Alternative debounce implementationuseDebounceB
- Callback-based debouncinguseTimeout
- Declarative setTimeoutuseTimeoutA
- Alternative timeout hookuseInterval
- Declarative setIntervaluseCountdown
- Countdown timer with controlsuseIsClient
- Client-side rendering detectionuseIsFirstRender
- First render detectionuseIsMounted
- Component mount statususeSSR
- Server-side rendering utilitiesuseEffectOnce
- Run effect only onceuseUpdateEffect
- Skip effect on first renderuseIsomorphicLayoutEffect
- SSR-safe layout effectuseEventListener
- Event listener managementuseImageOnLoad
- Image loading state managementuseUnloadWarning
- Page unload warninguseDarkMode
- Simple dark mode toggleuseTernaryDarkMode
- Advanced theme management (light/dark/system)import { useBoolean, useCounter, useArray } from "@gmana/react-hooks"
function StateExample() {
// Boolean state with helpers
const { value: isOpen, setTrue: open, setFalse: close, toggle } = useBoolean(false)
// Counter with operations
const { count, increment, decrement, reset } = useCounter(0)
// Array management
const { array, push, remove, filter, clear } = useArray([1, 2, 3])
return (
<div>
<button onClick={toggle}>{isOpen ? "Close" : "Open"}</button>
<button onClick={increment}>Count: {count}</button>
<div>Array: {array.join(", ")}</div>
<button onClick={() => push(Math.random())}>Add Random</button>
</div>
)
}
import { useHover, useOnClickOutside, useElementSize } from "@gmana/react-hooks"
function UIExample() {
const [setRef, { width, height }] = useElementSize()
const hoverRef = useRef(null)
const isHovered = useHover(hoverRef)
const dropdownRef = useRef(null)
const [isDropdownOpen, setIsDropdownOpen] = useState(false)
useOnClickOutside(dropdownRef, () => setIsDropdownOpen(false))
return (
<div ref={setRef}>
<p>
Element size: {width}x{height}
</p>
<div ref={hoverRef} style={{ background: isHovered ? "blue" : "gray" }}>
Hover me!
</div>
<div ref={dropdownRef}>
<button onClick={() => setIsDropdownOpen(!isDropdownOpen)}>Toggle Dropdown</button>
{isDropdownOpen && <div>Dropdown content</div>}
</div>
</div>
)
}
import { useFetch, useDebounce } from "@gmana/react-hooks"
function DataExample() {
const [query, setQuery] = useState("")
const debouncedQuery = useDebounce(query, 500)
const { data, error } = useFetch(debouncedQuery ? `https://api.example.com/search?q=${debouncedQuery}` : null)
return (
<div>
<input value={query} onChange={(e) => setQuery(e.target.value)} placeholder="Search..." />
{error && <p>Error: {error.message}</p>}
{data && <pre>{JSON.stringify(data, null, 2)}</pre>}
</div>
)
}
import { useDarkMode, useTernaryDarkMode } from "@gmana/react-hooks"
function ThemeExample() {
// Simple dark mode
const { isDarkMode, toggle, enable, disable } = useDarkMode()
// Advanced theme with system preference
const { isDarkMode: isAdvancedDark, ternaryDarkMode, setTernaryDarkMode } = useTernaryDarkMode()
return (
<div className={isDarkMode ? "dark" : "light"}>
<button onClick={toggle}>{isDarkMode ? "Light" : "Dark"} Mode</button>
<select value={ternaryDarkMode} onChange={(e) => setTernaryDarkMode(e.target.value)}>
<option value="light">Light</option>
<option value="dark">Dark</option>
<option value="system">System</option>
</select>
</div>
)
}
# Clone the repository
git clone https://github.com/sun-sreng/npm-gmana-react-hooks.git
cd npm-gmana-react-hooks
# Install dependencies
bun install
# Start development mode
bun run dev
bun run dev
- Start development mode with watchbun run build
- Build the librarybun run test
- Run testsbun run test:watch
- Run tests in watch modebun run lint
- Lint codebun run format
- Format code with Prettierbun run check
- Run linting and format checksWe use Vitest for testing with React Testing Library:
# Run all tests
bun run test
# Run tests in watch mode
bun run test:watch
# Run specific test file
bun run test src/lib/use-boolean.test.ts
The library is built using Rolldown for optimal performance:
bun run build
This generates:
dist/index.js
- ES module bundledist/index.d.ts
- TypeScript declarationsWe welcome contributions! Please see our Contributing Guidelines for details.
git checkout -b feature/new-hook
bun run test
src/lib/use-your-hook.ts
src/lib/use-your-hook.test.ts
src/index.ts
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by Sun Sreng
FAQs
React hooks
We found that @gmana/react-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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.