local ____lualib = require("lualib_bundle")
local __TS__Unpack = ____lualib.__TS__Unpack
local ____exports = {}
local ____context = require("hooks.context")
local hookContext = ____context.hookContext
local ____useEffect = require("hooks.useEffect")
local useEffect = ____useEffect.useEffect
local ____useState = require("hooks.useState")
local useState = ____useState.useState
____exports.useErrorBoundary = function(callback)
    local ____error, setError = __TS__Unpack(useState(nil))
    useEffect(
        function()
            local component = hookContext.currentComponent
            local oldComponentDidCatch = component.componentDidCatch
            component.componentDidCatch = function(____, err)
                setError(err)
                local ____callback_result_0 = callback
                if ____callback_result_0 ~= nil then
                    ____callback_result_0 = ____callback_result_0(err)
                end
                local ____oldComponentDidCatch_result_2 = oldComponentDidCatch
                if ____oldComponentDidCatch_result_2 ~= nil then
                    ____oldComponentDidCatch_result_2 = ____oldComponentDidCatch_result_2(nil, err)
                end
            end
        end,
        {}
    )
    return {
        ____error,
        function() return setError(nil) end
    }
end
return ____exports
