import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
const useAttach = (target)=>{
    const oldTargetRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(null);
    (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
        if (oldTargetRef.current && target !== oldTargetRef.current) oldTargetRef.current.onUnmount();
        oldTargetRef.current = target;
        target.onMount();
        return ()=>{
            target.onUnmount();
        };
    }, [
        target
    ]);
    return target;
};
export { useAttach };
