@primer/react
Version:
An implementation of GitHub's Primer Design System using React
35 lines • 1.48 kB
TypeScript
import { type ReactElement } from 'react';
export type RenderCounter = {
/** Total number of times the wrapped subtree has rendered (mount + updates). */
readonly count: number;
/** Number of mount renders. */
readonly mountCount: number;
/** Number of update renders (any cause). */
readonly updateCount: number;
/**
* Number of updates triggered inside the same commit cycle that produced the
* original render — i.e., a `setState` call from inside a `useLayoutEffect`
* that forced a synchronous re-render before paint. This is the canonical
* "nested update" / cascade signal; assert `nestedUpdateCount === 0` to pin
* that a component never forces a double-commit.
*/
readonly nestedUpdateCount: number;
/** Reset the counter. */
reset(): void;
};
/**
* Returns a `[Wrap, counter]` pair. Wrap the component under test with `Wrap`
* to count how many times its subtree renders. Useful for asserting that a
* single user interaction (or a stable prop) does not cause cascading renders.
*
* @example
* const [Wrap, counter] = createRenderCounter()
* render(<Wrap><MyComponent /></Wrap>)
* // ... interaction ...
* expect(counter.updateCount).toBe(1)
* expect(counter.nestedUpdateCount).toBe(0)
*/
export declare function createRenderCounter(id?: string): [(props: {
children: ReactElement | ReactElement[];
}) => ReactElement, RenderCounter];
//# sourceMappingURL=profiler.d.ts.map