@ashalfarhan/hooks
    TypeScript icon, indicating that this package has built-in type declarations

    0.2.2 • Public • Published

    Minimal React Hooks

    Just a simple React Hooks

    📦 Installation


    yarn add @ashalfarhan/hooks
    
    #or
    
    npm install @ashalfarhan/hooks --save

    🔧 Guide


    💻 useScroll

    const { scrolling, scrollBottom, scrollTop } = useScroll();
    • scrolling

      Type boolean

      Detect scrolling to bottom event

    • scrollBottom

      Type boolean

      Same as scrolling

    • scrollTop

      Type boolean

      Detect scrolling to top event

    🍳 useFetch

    const { result, status, error, loading, success } = useFetch('https://jsonplaceholder.typicode.com/posts');
    • result

      any

      Result of the fetch

      Note: Cast with generic parameter if you want to infer the type

    • status

      loading | success | error | idle

      Fetching status

    • error

      null | Error | any

    • success and loading

      boolean

      true If it is

    🧲 useToggle

    const { open, onToggle, onOpen, onClose, onSwitch } = useToggle();
    • open

      boolean

      Current state of toggle

      Note: Initially false, to change the initial state pass true to the useToggle parameter

    • onToggle

      function

      Function to toggle the state

    • onClose

      function

      Function to set the state to false

    • onOpen

      function

      Function to set the state to true

    • onSwitch

      function

      Function to set the state to the param that passed in

    Install

    npm i @ashalfarhan/hooks

    DownloadsWeekly Downloads

    21

    Version

    0.2.2

    License

    MIT

    Unpacked Size

    233 kB

    Total Files

    20

    Last publish

    Collaborators

    • ashalfarhan