set-state-compare
Version:
setState for React that compares with the current state and only sets the state if changed.
53 lines • 1.6 kB
TypeScript
export default useShape;
/**
* @param {typeof Shape} ShapeClass
* @returns {import("react").ReactElement | null}
*/
export function shapeComponent(ShapeClass: typeof Shape): any | null;
export class Shape {
__mounting: boolean;
__mounted: boolean;
setStates: {};
__setStatesActual: {};
__setStatesLater: {};
/** @type {Record<string, any>} */
state: Record<string, any>;
/** @type {Record<string, any>} */
props: Record<string, any>;
/** @type {Record<string, any>} */
meta: Record<string, any>;
m: any;
p: any;
s: any;
__afterRender(): void;
/**
* @param {Record<string, any>} statesList
* @param {object} [args]
* @param {boolean} [args.silent]
*/
set(statesList: Record<string, any>, args?: {
silent?: boolean;
}): void;
/** @param {Record<string, any>} newMeta */
updateMeta(newMeta: Record<string, any>): void;
/** @param {Record<string, any>} newProps */
updateProps(newProps: Record<string, any>): void;
/**
* @param {string} stateName
* @param {any} defaultValue
* @returns {void}
*/
useState(stateName: string, defaultValue: any): void;
/** @param {Record<string, any> | string[]} statesList */
useStates(statesList: Record<string, any> | string[]): void;
}
/**
* @param {Record<string, any>} props
* @param {object} [opts]
* @param {typeof Shape} [opts.shapeClass]
* @returns {Shape}
*/
declare function useShape(props: Record<string, any>, opts?: {
shapeClass?: typeof Shape;
}): Shape;
//# sourceMappingURL=use-shape.d.ts.map