recharts
Version:
React charts
21 lines (20 loc) • 1.31 kB
TypeScript
import { ReactElement, ReactNode } from 'react';
/**
* Reads the `Cell` children of a graphical item and returns a reference that is stable
* for as long as the cells themselves do not change.
*
* `findAllByType` allocates a new array on every call, and JSX allocates new `Cell` elements
* every time the parent renders. Cells are an argument to the memoized selectors that compute
* the graphical item shapes, so an unstable reference here is a selector cache miss, which
* produces a new array of shapes, which changes the animationId, which starts a new animation.
*
* That animation interpolates between shapes that hold identical values, so nothing appears to
* move, but `isAnimating` still flips for the whole animationDuration. Labels are hidden while
* a graphical item animates, so they blank out on every unrelated re-render of the surrounding
* component - for example while the pointer moves over the chart. The animation callbacks fire
* spuriously too, and every shape re-renders at frame rate for as long as it runs.
*
* @param children children of the graphical item, some of which may be `Cell` elements
* @returns the Cell children; the same reference as last render if they are unchanged
*/
export declare function useCells(children: ReactNode): ReadonlyArray<ReactElement>;