Method UseInsertionEffect
- Namespace
- Velvet
- Assembly
- Velvet.Docs.dll
UseInsertionEffect(Func<Action?>?, object?[]?)
Position-based insertion effect. Runs synchronously after Render completes and before any UseLayoutEffect(Func<Action?>?, object?[]?) of the same commit. Intended for injecting styles: the DOM is not yet laid out, so the body must not read layout or refs — use UseLayoutEffect(Func<Action?>?, object?[]?) for that.
public static void UseInsertionEffect(Func<Action?>? factory, object?[]? deps = null)
Parameters
factoryFunc<Action>Effect body. Returns a cleanup Action invoked on unmount or when
depschange.depsobject[]Dependency array. When deeply equal to the previous render, the effect is skipped. When omitted or
null, the effect runs on every render.
UseInsertionEffect(Func<IDisposable>, object?[]?)
IDisposable variant. Dispose() is called when deps change.
public static void UseInsertionEffect(Func<IDisposable> factory, object?[]? deps = null)
Parameters
factoryFunc<IDisposable>Effect body returning an System.IDisposable. Disposed on unmount or when
depschange.depsobject[]Dependency array. When deeply equal to the previous render, the effect is skipped. When omitted or
null, the effect runs on every render.