function Component.__update(O,U,A)if config.internalTypeChecks then internalAssert(Type.of(O)==Type.StatefulComponentInstance,"\073\110\118\097\108\105\100 \117\115\101 \111\102 \096\095\095\117\112\100\097\116\101\096")internalAssert(Type.of(U)==Type.Element or U==nil,"\069\120\112\101\099\116\101\100 \097\114\103 \035\049 \116\111 \098\101 \111\102 \116\121\112\101 \069\108\101\109\101\110\116 \111\114 \110\105\108")internalAssert(typeof(A)=="\116\097\098\108\101"or A==nil,"\069\120\112\101\099\116\101\100 \097\114\103 \035\050 \116\111 \098\101 \111\102 \116\121\112\101 \116\097\098\108\101 \111\114 \110\105\108")end local p=O[InternalData]local C=p.componentClass local I=O.props if U~=nil then I=U.props if C.defaultProps~=nil then I=assign({},C.defaultProps,I)end O:__validateProps(I)end local c=0 repeat local U local C=nil if p.pendingState~=nil then C=p.pendingState p.pendingState=nil end if A~=nil or I~=O.props then if C==nil then U=A or O.state else U=assign(C,A)end local p=O:__getDerivedState(I,U)if p~=nil then U=assign({},U,p)end A=nil else U=C end if not O:__resolveUpdate(I,U)then return false end c=c+1 if c>MAX_PENDING_UPDATES then error(tooManyUpdatesMessage:format(tostring(p.componentClass)),3)end until p.pendingState==nil return true end

function Component:__update(updatedElement, updatedState)
	if config.internalTypeChecks then
		internalAssert(Type.of(self) == Type.StatefulComponentInstance, "Invalid use of `__update`")
		internalAssert(
			Type.of(updatedElement) == Type.Element or updatedElement == nil,
			"Expected arg #1 to be of type Element or nil"
		)
		internalAssert(
			typeof(updatedState) == "table" or updatedState == nil,
			"Expected arg #2 to be of type table or nil"
		)
	end

	local internalData = self[InternalData]
	local componentClass = internalData.componentClass

	local newProps = self.props
	if updatedElement ~= nil then
		newProps = updatedElement.props

		if componentClass.defaultProps ~= nil then
			newProps = assign({}, componentClass.defaultProps, newProps)
		end

		self:__validateProps(newProps)
	end

	local updateCount = 0
	repeat
		local finalState
		local pendingState = nil

		-- Consume any pending state we might have
		if internalData.pendingState ~= nil then
			pendingState = internalData.pendingState
			internalData.pendingState = nil
		end

		-- Consume a standard update to state or props
		if updatedState ~= nil or newProps ~= self.props then
			if pendingState == nil then
				finalState = updatedState or self.state
			else
				finalState = assign(pendingState, updatedState)
			end

			local derivedState = self:__getDerivedState(newProps, finalState)

			if derivedState ~= nil then
				finalState = assign({}, finalState, derivedState)
			end

			updatedState = nil
		else
			finalState = pendingState
		end

		if not self:__resolveUpdate(newProps, finalState) then
			-- If the update was short-circuited, bubble the result up to the caller
			return false
		end

		updateCount = updateCount + 1

		if updateCount > MAX_PENDING_UPDATES then
			error(tooManyUpdatesMessage:format(tostring(internalData.componentClass)), 3)
		end
	until internalData.pendingState == nil

	return true
end
