Call the function on every request animation frame with the ability to pause and play
Frames: 0
Delta: 0ms
FPS: 60
isPaused: false
const [count, setCount] = useState(0)
const [delta, setDelta] = useState(0)
const controls = useRafFn(
({ delta }) => {
setCount(($count) => $count + 1)
setDelta(delta)
},
{
fpsLimit: 60,
immediate: true,
}
)
import { const useRafFn: (callback: (arg: RefFnArg) => void, options?: RefFnOptions) => {
isActive: boolean;
start: () => void;
stop: () => void;
}
useRafFn } from "@kaioken-core/hooks"
const const controls: {
isActive: boolean;
start: () => void;
stop: () => void;
}
controls = function useRafFn(callback: (arg: RefFnArg) => void, options?: RefFnOptions): {
isActive: boolean;
start: () => void;
stop: () => void;
}
useRafFn((options: RefFnArg
options) => {}, {
fpsLimit?: number | undefined
fpsLimit: var undefined
undefined,
immediate?: boolean | undefined
immediate: false,
})