(work *EffectWorkElem, hook *Hook)
| 363 | } |
| 364 | |
| 365 | func (r *RootElem) runEffect(work *EffectWorkElem, hook *Hook) { |
| 366 | defer func() { |
| 367 | comp := r.CompMap[work.WaveId] |
| 368 | compName := "" |
| 369 | if comp != nil { |
| 370 | compName = comp.ContainingComp |
| 371 | } |
| 372 | util.PanicHandler(fmt.Sprintf("UseEffect run - comp: %s", compName), recover()) |
| 373 | }() |
| 374 | if hook.Fn == nil { |
| 375 | return |
| 376 | } |
| 377 | effectCtx := &EffectContextImpl{ |
| 378 | WorkElem: *work, |
| 379 | WorkType: "run", |
| 380 | Root: r, |
| 381 | } |
| 382 | unmountFn := withGlobalEffectCtx(effectCtx, func() func() { |
| 383 | return hook.Fn() |
| 384 | }) |
| 385 | hook.UnmountFn = unmountFn |
| 386 | } |
| 387 | |
| 388 | // this will be called by the frontend to say the DOM has been mounted |
| 389 | // it will eventually send any updated "refs" to the backend as well |
no test coverage detected