@primer/react
Version:
An implementation of GitHub's Primer Design System using React
15 lines • 814 B
TypeScript
/**
* When the value that initialized the state changes
* this hook will update the state to the new value, immediately.
*
* This uses an Object.is comparison to determine if the value has changed by default
*
* If you use a non-primitive value as the initial value, you should provide a custom isEqual function
*
* This is adapted almost directly from https://beta.reactjs.org/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes
*/
export declare const useSyncedState: <T>(initialValue: T | (() => T), { isPropUpdateDisabled, isEqual }?: {
isPropUpdateDisabled?: boolean | undefined;
isEqual?: ((value1: any, value2: any) => boolean) | undefined;
}) => readonly [T, import("react").Dispatch<import("react").SetStateAction<T>>];
//# sourceMappingURL=useSyncedState.d.ts.map