use_memo
def use_memo(
f: Any,
dependencies: Any | None = None,
debug_name: str = None
) -> Any:
...
use_memo
stores (memoize) the function return on first render, and then excludes it from being re-executed, except when one of the dependencies
changes. dependencies
can take the value None
, in which case dependencies are automatically obtained from nonlocal variables. If an empty list is passed as dependencies
instead, the function is only executed once over the entire lifetime of the component.
Not to be confused with memorize which can cache multiple return values and which can be used outside of component.
See also the Reacton docs.