UseLocal creates a component-local atom that is automatically cleaned up when the component unmounts. The atom is created with a unique name based on the component's wave ID and hook index. This hook must be called within a component context.
(initialVal T)
| 129 | // The atom is created with a unique name based on the component's wave ID and hook index. |
| 130 | // This hook must be called within a component context. |
| 131 | func UseLocal[T any](initialVal T) Atom[T] { |
| 132 | rc := engine.GetGlobalRenderContext() |
| 133 | if rc == nil { |
| 134 | panic("UseLocal must be called within a component (no context)") |
| 135 | } |
| 136 | atomName := engine.UseLocal(rc, initialVal) |
| 137 | return Atom[T]{ |
| 138 | name: atomName, |
| 139 | client: engine.GetDefaultClient(), |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | // UseGoRoutine manages a goroutine lifecycle within a component. |
| 144 | // It spawns a new goroutine with the provided function when dependencies change, |
no test coverage detected