Giter Site home page Giter Site logo

muskanmahajan37 / web Goto Github PK

View Code? Open in Web Editor NEW

This project forked from react-hookz/web

0.0 0.0 0.0 2.66 MB

React hooks done right, for browser and SSR.

Home Page: https://react-hookz.github.io/web/

License: MIT License

JavaScript 3.56% TypeScript 96.21% HTML 0.23%

web's Introduction

@react-hookz/web

NPM Version NPM Downloads NPM Dependents Build Coverage Types Tree Shaking

× DOCS × DISCORD × CHANGELOG ×


@react-hookz/web is a library of general-purpose React hooks built with care and SSR compatibility in mind.

Install

This one is pretty simple, everyone knows what to do:

npm i @react-hookz/web
# or
yarn add @react-hookz/web

As hooks was introduced to the world in React 16.8, @react-hookz/web requires - you guessed it - react and react-dom 16.8+.
Also, as React does not support IE, @react-hookz/web does not do so either. You'll have to transpile your node-modules in order to run in IE.

Usage

This package provides three levels of compilation:

  1. Main, the /cjs folder — CommonJS modules, with ES5 lang level.
  2. ESM, the /esm folder — it is ES modules (browser compatible), with ES5 lang level.
  3. ESNext, the /esnext folder — it is ES modules (browser compatible), with ESNext lang level.

So, if you need the useMountEffect hook, depending on your needs, you can import in three ways (there are actually more, but these are the three most common):

// in case you need cjs modules
import { useMountEffect } from "@react-hookz/web";
// in case you need esm modules
import { useMountEffect } from "@react-hookz/web/esm";
// in case you want all the recent ES features
import { useMountEffect } from "@react-hookz/web/esnext";

Hooks list

  • Callback

    • useDebounceCallback — Makes passed function debounced, otherwise acts like useCallback.
    • useRafCallback — Makes passed function to be called within next animation frame.
  • Lifecycle

  • State

    • useMediatedState — Like useState, but every value set is passed through a mediator function.
    • usePrevious — Returns the value passed to the hook on previous render.
    • useSafeState — Like useState, but its state setter is guarded against sets on unmounted component.
    • useToggle — Like useState, but can only become true or false.
  • Navigator

  • Miscellaneous

    • useSyncedRef — Like useRef, but it returns immutable ref that contains actual value.
  • Side-effect

  • Sensor

    • useResizeObserver — Invokes a callback whenever ResizeObserver detects a change to target's size.
    • useMeasure — Uses ResizeObserver to track element dimensions and re-render component when they change.
  • Dom

web's People

Contributors

axelboc avatar dependabot[bot] avatar joeduncko avatar lint-action avatar semantic-release-bot avatar xobotyi 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.