Skip to content

UseEffect

method
cref: M:Microsoft.UI.Reactor.Core.RenderContext.UseEffect(System.Action,System.Object[])

Learn more: Hooks, Effects

Overloads

UseEffect(Action, object[])

method
cref: M:Microsoft.UI.Reactor.Core.RenderContext.UseEffect(System.Action,System.Object[])

Summary

Runs a side effect after render. The effect re-runs when any dependency changes. Pass an empty array for "run once on mount" semantics. Returns a cleanup action that runs before the next effect or on unmount.

UseEffect(Func<Action>, object[])

method
cref: M:Microsoft.UI.Reactor.Core.RenderContext.UseEffect(System.Func{System.Action},System.Object[])

Summary

Like UseEffect but the effect returns a cleanup function.

UseEffect<T1>(Action, T1)

method
cref: M:Microsoft.UI.Reactor.Core.RenderContext.UseEffect``1(System.Action,``0)

Summary

Single-dependency UseEffect overload that avoids the params object[] allocation (and value-type boxing) on the deps-unchanged path. Semantically identical to the params overload called with one dependency: the effect re-runs only when d1 changes.

Discussion

If d1's compile-time type is an array of reference types (e.g. string[]), it is treated as a dependency list and compared element-wise — matching the params object[] overload — not as a single reference-compared value. A dependency whose static type is not an array is always compared as one value, even if its runtime value happens to be an array.

UseEffect<T1>(Func<Action>, T1)

method
cref: M:Microsoft.UI.Reactor.Core.RenderContext.UseEffect``1(System.Func{System.Action},``0)

Summary

Single-dependency cleanup-flavor UseEffect overload that avoids the params object[] allocation on the deps-unchanged path. Semantically identical to the params overload called with one dependency.

Discussion

If d1's compile-time type is an array of reference types (e.g. string[]), it is treated as a dependency list and compared element-wise — matching the params object[] overload — not as a single reference-compared value. A dependency whose static type is not an array is always compared as one value, even if its runtime value happens to be an array.

UseEffect<T1, T2>(Action, T1, T2)

method
cref: M:Microsoft.UI.Reactor.Core.RenderContext.UseEffect``2(System.Action,``0,``1)

Summary

Two-dependency UseEffect overload that avoids the params object[] allocation on the deps-unchanged path. Re-runs when either dependency changes.

UseEffect<T1, T2>(Func<Action>, T1, T2)

method
cref: M:Microsoft.UI.Reactor.Core.RenderContext.UseEffect``2(System.Func{System.Action},``0,``1)

Summary

Two-dependency cleanup-flavor UseEffect overload that avoids the params object[] allocation on the deps-unchanged path.

UseEffect<T1, T2, T3>(Action, T1, T2, T3)

method
cref: M:Microsoft.UI.Reactor.Core.RenderContext.UseEffect``3(System.Action,``0,``1,``2)

Summary

Three-dependency UseEffect overload that avoids the params object[] allocation on the deps-unchanged path. Re-runs when any dependency changes.

UseEffect<T1, T2, T3>(Func<Action>, T1, T2, T3)

method
cref: M:Microsoft.UI.Reactor.Core.RenderContext.UseEffect``3(System.Func{System.Action},``0,``1,``2)

Summary

Three-dependency cleanup-flavor UseEffect overload that avoids the params object[] allocation on the deps-unchanged path.