Code Monkey home page Code Monkey logo

use-hooks's Introduction

use-hooks

npm version Greenkeeper badge

https://usehooks.com as an npm package with TypeScript type definitions.

Installation

npm install use-hooks
yarn add use-hooks

Available hooks

Hooks marked with "*" have minor differences (read below).

Differences

useAnimation

To supply a custom easing function just pass it as a first argument:

import { useAnimation } from 'use-hooks'

const inQuart = (t) => t * t * t * t
function MyComponent() {
	const animation = useAnimation(inQuart, 250)

	// ...
}

useDarkMode

The class name and element are hard coded on the website but in this package they're changable:

import { useDarkMode } from 'use-hooks'

const rootElement = document.getElementById('my-root-element')
function App() {
	useDarkMode('my-dark-mode-class-name', rootElement)

	// ...
}

useHistory

Added initialValue to the clear callbacks dependencies.

useKeyPress

A second useDependencies argument was added allowing the effect to re-run when arguments change.

useMedia

A fourth useDependencies argument was added allowing the effect to re-run when arguments change.

useOnScreen

A third useDependencies argument was added allowing the effect to re-run when arguments change.

useScript

Converted an Array.prototype.includes call to an Array.prototype.indexOf call to support ES5 environments.

useWindowSize

isClient boolean and getSize function moved out of hook body.

Credits

Thanks to @gabe_ragland for creating and maintaining https://usehooks.com

Thanks to @turbobabr for donating use-hooks package name

use-hooks's People

Contributors

dependabot-preview[bot] avatar dimitarnestorov avatar dependabot-support avatar dependabot[bot] avatar levabala avatar greenkeeper[bot] avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.