MCPcopy
hub / github.com/wavetermdev/waveterm / UseEffect

Function UseEffect

tsunami/app/hooks.go:119–126  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

117// or when the component unmounts. Dependencies use shallow comparison, just like React.
118// This hook must be called within a component context.
119func 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.

Callers 2

app.goFile · 0.92
UseGoRoutineFunction · 0.70

Calls 2

GetGlobalRenderContextFunction · 0.92
UseEffectFunction · 0.92

Tested by

no test coverage detected