--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____context = require("hooks.context")
local getOrInitHook = ____context.getOrInitHook
local hookContext = ____context.hookContext
require("hooks.reconcilerHooks")
local ____reconciler = require("reconciler")
local scheduleUpdate = ____reconciler.scheduleUpdate
____exports.useReducer = function(reducer, initialState)
    local state = getOrInitHook(
        "reducer",
        function() return {type = "reducer"} end
    )
    state.reducer = reducer
    if not state.component then
        state.value = {
            initialState,
            function(action)
                local nextValue = state.reducer(state.value[1], action)
                if state.value[1] ~= nextValue then
                    state.value = {nextValue, state.value[2]}
                    scheduleUpdate(state.component.instance)
                end
            end
        }
        state.component = hookContext.currentComponent
    end
    return state.value
end
return ____exports
