util/cache

View cache utility functions.

Methods

(static) cacheComponent(type, prefix, transform)

Create cached component from a given component class. The cache ID is caculated from the input props.
Source:
Parameters:
Name Type Description
type Component JSX component class
prefix string Cache ID prefix
transform function Transform the input props to target props and its result is used to compute cache ID
Returns:
The new cachable functional component, which uses the transform function and the component props to calculate the cache ID.
The cache ID will be used to determine whether the same element with the exact same props has been created and cached. If so, the cached element will be returned. If the cache ID can be computed, a new element will be created use the createElement function of the inferno.js, then it will be cached and returned. If the transformed props is empty (!transform(props)), the cachable functional component will also return null element when createElement is called on it.