MCPcopy
hub / github.com/TanStack/router / usePrevious

Function usePrevious

packages/solid-router/src/utils.ts:3–21  ·  view source on GitHub ↗
(fn: () => boolean)

Source from the content-addressed store, hash-verified

1import * as Solid from 'solid-js'
2
3export const usePrevious = (fn: () => boolean) => {
4 return Solid.createMemo(
5 (
6 prev: { current: boolean | null; previous: boolean | null } = {
7 current: null,
8 previous: null,
9 },
10 ) => {
11 const current = fn()
12
13 if (prev.current !== current) {
14 prev.previous = prev.current
15 prev.current = current
16 }
17
18 return prev
19 },
20 )
21}
22
23/**
24 * React hook to wrap `IntersectionObserver`.

Callers 1

TransitionerFunction · 0.90

Calls 1

fnFunction · 0.50

Tested by

no test coverage detected