Skip to content

@epikodelabs/streamix


@epikodelabs/streamix / react/src/public-api / useAtom

Function: useAtom() ​

useAtom<T>(factory): T

Defined in: projects/libraries/streamix/react/src/lib/runtime.ts:276

Creates a component-owned atom once per mounted component instance. Factories must be render-pure: React may invoke them for an abandoned or Strict-Mode development render. The owned atom is disposed after unmount.

Ownership delegates to the same Strict-Mode-safe slot the compiler uses: the dispose pass is cancelled when the instance is re-owned by the remount of the same component, so a simulated Strict-Mode teardown never disposes an atom the committed component still holds.

Type Parameters ​

T ​

T extends Readable<any>

Parameters ​

factory ​

() => T

Returns ​

T

Released under the MIT License.