You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
portainer/app/react-tools/apply-set-state-action.ts

13 lines
339 B

import { SetStateAction } from 'react';
export function applySetStateAction<T>(applier: SetStateAction<T>, values?: T) {
if (isFunction(applier)) {
return values ? applier(values) : undefined;
}
return applier;
function isFunction(value: unknown): value is (prevState: T) => T {
return typeof value === 'function';
}
}