memo
The memo() function evaluates a function only once then memorizes the result. The first access to value triggers the evaluation, and subsequent accesses return the same value without recalculation.
Interactive example
Syntax
typescript
interface Memoized<
GenericValue extends unknown
> {
readonly value: GenericValue;
}
function memo<
GenericOutput extends unknown
>(
theFunction: () => GenericOutput
): Memoized<GenericOutput>;Parameters
theFunction: Function evaluated only once to produce the memorized value.
Return value
A Memoized object with the value property containing the single result.
See also
promiseObject- Resolution of asynchronous objectsexternalPromise- Controllable promise
