Skip to content

@technobuddha > react-hooks > React

Hooks

NameTypeDescription
useDerivedStateFunctionLike useState, but the value is re-initialized from initialValue whenever deps change. Allows both derived (from dependencies) and manual updates. Useful for state that depends on props or other values, but can also be set directly.
useHMRFunctionReact hook that tracks Hot Module Replacement (HMR) updates in a Vite development environment.
useLocalFunctionProvides a mutable value that persists for the lifetime of the component, similar to useRef, but with a convenient setter function like useState. Updating the value does not cause a re-render.
useLocalStorageFunctionSimilar to React.useState, returns a stateful value and a function to update it. The state value is also saved in localStorage.
usePreviousFunctionTracks the previous value of a variable across renders.
useWhyDidIRenderFunctionLogs to the console whenever the given component re-renders and its props have changed. Useful for debugging unnecessary or unexpected re-renders during development.
useWindowSizeFunctionGets the current window size, including the dimensions of the scroll bars.