import React, { useEffect, useState } from "react";
import { initializationErrorState } from "./initializationErrorState";
/**
 * 初始化错误抛出组件
 * 
 * 当检测到初始化错误时，主动抛出错误给 ErrorBoundary 捕获
 */ export const InitializationErrorThrower = ()=>{
    const [error, setError] = useState(null);
    useEffect(()=>{
        // 检查初始错误
        const currentError = initializationErrorState.getError();
        if (currentError) {
            setError(currentError);
            return;
        }
        // 订阅错误变化
        const unsubscribe = initializationErrorState.subscribe(()=>{
            const newError = initializationErrorState.getError();
            setError(newError);
        });
        return unsubscribe;
    }, []);
    // 如果有错误，抛出错误给 ErrorBoundary
    if (error) {
        throw error;
    }
    return null;
};

//# sourceMappingURL=InitializationErrorThrower.js.map