Skip to main content

usePersist

It returns the same function identifier no matter whether the callback parameter is changed or not. The returned function is used in the same way as the callback.

API​

function usePersist<T extends (...args: any[]) => any>(
callback: T
): (...args: Parameters<T>) => ReturnType<T>;

Example​

import React from "react";
import { usePersist } from "@lilib/hooks";

function Example() {
const callback = usePersist(() => {
// Do something.
});
...
}