UseEffect is the tsunami analog to React's useEffect hook. It queues effects to run after the render cycle completes. The function can return a cleanup function that runs before the next effect or when the component unmounts. Dependencies use shallow comparison, just like React. This hook must be ca
(fn func() func(), deps []any)
| 117 | // or when the component unmounts. Dependencies use shallow comparison, just like React. |
| 118 | // This hook must be called within a component context. |
| 119 | func UseEffect(fn func() func(), deps []any) { |
| 120 | // note UseEffect never actually runs anything, it just queues the effect to run later |
| 121 | rc := engine.GetGlobalRenderContext() |
| 122 | if rc == nil { |
| 123 | panic("UseEffect must be called within a component (no context)") |
| 124 | } |
| 125 | engine.UseEffect(rc, fn, deps) |
| 126 | } |
| 127 | |
| 128 | // UseLocal creates a component-local atom that is automatically cleaned up when the component unmounts. |
| 129 | // The atom is created with a unique name based on the component's wave ID and hook index. |
no test coverage detected