MCPcopy
hub / github.com/NervJS/nerv / unmountComponent

Function unmountComponent

packages/nerv/src/lifecycle.ts:303–320  ·  view source on GitHub ↗
(vnode: FullComponent)

Source from the content-addressed store, hash-verified

301}
302
303export function unmountComponent (vnode: FullComponent) {
304 const component = vnode.component
305 component.hooks.forEach((hook) => {
306 if (isFunction(hook.cleanup)) {
307 hook.cleanup()
308 }
309 })
310 if (isFunction(component.componentWillUnmount)) {
311 errorCatcher(() => {
312 (component as any).componentWillUnmount()
313 }, component)
314 }
315 component._disable = true
316 unmount(component._rendered)
317 if (!isNullOrUndef(vnode.ref)) {
318 Ref.detach(vnode, vnode.ref, vnode.dom as any)
319 }
320}
321
322function callGetDerivedStateFromProps (props, state, inst) {
323 const { getDerivedStateFromProps } = inst.constructor

Callers 1

destroyMethod · 0.90

Calls 6

isFunctionFunction · 0.90
unmountFunction · 0.90
isNullOrUndefFunction · 0.90
errorCatcherFunction · 0.85
cleanupMethod · 0.80
componentWillUnmountMethod · 0.65

Tested by

no test coverage detected