Skip to main content

with_hook_context

Function with_hook_context 

Source
pub fn with_hook_context<F, R>(context: HookContext, f: F) -> R
where F: FnOnce() -> R,
Expand description

Runs a closure with the given HookContext set as the active context.

This is called by the renderer before invoking a DynamicNode’s render function, enabling use_signal and other hooks to access and persist state across re-renders.

§Arguments

  • HookContext - The hook context to set as active.
  • FnOnce() -> R - The closure to execute with the active context.

§Returns

  • R - The return value of the closure.