import type { Component } from 'react' ; import type { Fiber } from 'react-reconciler' ; import { ParentFiber } from './parentFiber' ; import { getFiberFromClassInstance } from '../fiber/getFiber' ; param instance param findFiber returns export function createParent ( instance , findFiber ? ) { const parent = new ParentFiber ( ) ; const { componentDidMount , componentWillUnmount } = instance ; instance . componentDidMount = function cdm ( ) { const fiber = getFiberFromClassInstance ( instance ) ; parent . setFiber ( fiber ) ; parent . setFinder ( findFiber ) ; if ( typeof componentDidMount === 'function' ) { componentDidMount . call ( this ) ; } } ; instance . componentWillUnmount = function cwu ( ) { if ( typeof componentWillUnmount === 'function' ) { componentWillUnmount . call ( this ) ; } parent . clear ( ) ; } ; return parent ; }