All Hooks
this project was heavily inspired by usehooks.dev and built with the purpose of increasing qwik ecosystem. by: @victorditadi

usePrevious

Track the previous value of a variable with usePrevious.

INSTALL:
npm i @ditadi/qwik-hooks
DESCRIPTION:The usePrevious hook is a useful tool for tracking the previous value of a variable in a functional component. This can be particularly handy in scenarios where it is necessary to compare the current value with the previous one, such as triggering actions or rendering based on changes.
PARAMETERS
NameTypeDescription
newValueSignal<any>The new value to track and return the previous of.
RETURN VALUEThe usePrevious hook returns an array with the following elements:
NameTypeDescription
previousValueSignal<any>The previous value of the provided newValue.
DEMO:

usePrevious

Example: