marsidev / react-hooks

A collection of common React hooks. Made with TypeScript.

Home Page:https://www.npmjs.com/package/@marsidev/react-hooks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@marsidev/react-hooks

npm version GitHub Actions status PRs Welcome Tested with Vitest CI Score Twitter Follow

Introduction

This is a collection of common React Hooks that I use in my React projects.

Bootstraped with antfu/starter-ts.

Inspired by usehooks-ts, @restart/hooks, and @chakra-ui/hooks.

Installation

  • Using npm

    npm i @marsidev/react-hooks
  • Using pnpm

    pnpm add @marsidev/react-hooks
  • Using yarn

    yarn add @marsidev/react-hooks

Example

import { useScrollY } from '@marsidev/react-hooks'
import { Header, Footer, ScrollToTop } from '~/components'

export const Layout = ({ children }) => {
  const { offsetPassed } = useScrollY(400)

  return (
    <div>
      <Header />
      <main>{children}</main>
      <Footer />
      {offsetPassed && <ScrollToTop />}
    </div>
  )
}

Available Hooks

  • useCopyElementToClipboard
  • useCopyToClipboard
  • useInput
  • useRendered
  • useSafeLayoutEffect
  • useScrollY
  • useWindowSize

About

A collection of common React hooks. Made with TypeScript.

https://www.npmjs.com/package/@marsidev/react-hooks

License:MIT License


Languages

Language:TypeScript 100.0%