local C=require(script.Parent.Hook)local e=require(script.Parent.Symbol)local O=e.named("\078\111\110\101")local function o()return newproxy(true)end local D=C:extend("\083\116\097\116\101")function D.init(C)C.key=o()end function D.use(e,C)local o=e.node.state[e.key]if o==nil then o=C elseif o==O then o=nil end local D=function(C)if C==nil then C=O end e.node:setState({[e.key]=C})end return o,D end return D
local Hook = require(script.Parent.Hook)
local Symbol = require(script.Parent.Symbol)

-- Used to track if a state is nil or uninitialized
-- Different from Roact.None
local None = Symbol.named("None")

local function createStateKey()
	return newproxy(true)
end

local StateHook = Hook:extend("State")

function StateHook:init()
	self.key = createStateKey()
end

function StateHook:use(initialValue)
	local state = self.node.state[self.key]

	if state == nil then
		state = initialValue
	elseif state == None then
		state = nil
	end

	local setState = function(newState)
		if newState == nil then
			newState = None
		end

		self.node:setState({
			[self.key] = newState
		})
	end

	return state, setState
end

return StateHook