Skip to content

Latest commit

 

History

History
112 lines (65 loc) · 2.34 KB

API.md

File metadata and controls

112 lines (65 loc) · 2.34 KB

use-optimized-selector

use-optimized-selector

Table of contents

Type aliases

Functions

Type aliases

Comparer

Ƭ Comparer<Return>: (prev: Return, next: Return) => boolean

A memoized or constant function in the form of:

(prevValue, nextValue) => boolean

Return true when objects are considered equivalent.

Type parameters:

Name
Return

Type declaration:

▸ (prev: Return, next: Return): boolean

Parameters:

Name Type
prev Return
next Return

Returns: boolean

Defined in: use-optimized-selector.ts:22


Selector

Ƭ Selector<Value, Return>: (value: Value) => Return

A memoized or constant function in the form of:

(sourceValue) => derivedValue

Type parameters:

Name
Value
Return

Type declaration:

▸ (value: Value): Return

Parameters:

Name Type
value Value

Returns: Return

Defined in: use-optimized-selector.ts:13

Functions

useOptimizedSelector

ConstuseOptimizedSelector<Value, Return>(selector: Selector<Value, Return>, comparer?: Comparer<Return>): Selector<Value, Return>

A hook that caches the value of a selector given an optional comparer.

It will return the previous value when present and comparer returns true, bailing out of setState and consequent renders.

Useful for optimizing selectors for useContextSelector, useSubscriptions, useMutableSource, etc.

Type parameters:

Name
Value
Return

Parameters:

Name Type Description
selector Selector<Value, Return> A memoized or constant selector
comparer Comparer<Return> A memoized or constant comparer

Returns: Selector<Value, Return>

Defined in: use-optimized-selector.ts:60