reakit-utils
Version:
Reakit utils
13 lines (12 loc) • 407 B
TypeScript
import * as React from "react";
/**
* Receives a `setState` argument and calls it with `currentValue` if it's a
* function. Otherwise return the argument as the new value.
*
* @example
* import { applyState } from "reakit-utils";
*
* applyState((value) => value + 1, 1); // 2
* applyState(2, 1); // 2
*/
export declare function applyState<T>(argument: React.SetStateAction<T>, currentValue: T): T;