Skip to content

Latest commit

 

History

History
26 lines (18 loc) · 699 Bytes

README.md

File metadata and controls

26 lines (18 loc) · 699 Bytes

useLazyState

A React hook that allows you to trigger a callback when the state changes without updating the component.

Usage

import { useLazyState } from 'hamo'

function App() {
  const [setState, getState] = useLazyState(0, (value, previousValue) => {
    console.log(value, previousValue)
  })
}

Parameters

  • initialValue (any): The initial value of the state.
  • callback (function): The callback function to be called when the state changes.
  • deps (array): The dependencies to be used in the callback function.

Return Value

  • setState (function): The function to update the state.
  • getState (function): The function to get the current value of the state.