1.4.3 • Published 2 years ago

use-cleared-memo v1.4.3

Weekly downloads
11
License
MIT
Repository
github
Last release
2 years ago

Stable Release Types Included GZip Size Treeshaking Blazing Fast license


Are you building a hook or functional React component that needs to predictably clear and/or hydrate memoized values in an easy-to-use way? Opportunities are almost endless; no matter if you're subscribing to external state, initializing timers or intervals, or creating a new instance of some object every time deps change that eventually needs to be deconstructed, useClearedMemo will be there for you to do the job.

useClearedMemo(getFn, clearFn, deps, clearFnDeps) ⇒ T

Kind: global function
Returns: T - The value to be memoized and cleared appropriately.

ParamTypeDescription
getFnfunctionReturns the memoized value that is to be cleared.
clearFnfunctionClears the previously memoized value when the component unmounts or the deps change.
depsReadonlyArrayIdentities that the getFn depends on. When changed, the previously memoized value will be cleared and the getFn will be called to retrieve the new value.
clearFnDepsReadonlyArrayIdentities that the clearFn depends on.

Authors


MIT License.