function Component.__mount(r,a,D)if config.internalTypeChecks then internalAssert(Type.of(r)==Type.StatefulComponentClass,"\073\110\118\097\108\105\100 \117\115\101 \111\102 \096\095\095\109\111\117\110\116\096")internalAssert(Type.of(D)==Type.VirtualNode,"\069\120\112\101\099\116\101\100 \097\114\103 \035\050 \116\111 \098\101 \111\102 \116\121\112\101 \086\105\114\116\117\097\108\078\111\100\101")end local s=D.currentElement local Y=D.hostParent local N={reconciler=a;virtualNode=D,componentClass=r,lifecyclePhase=ComponentLifecyclePhase.Init}local o={[Type]=Type.StatefulComponentInstance;[InternalData]=N}setmetatable(o,r)D.instance=o local P=s.props if r.defaultProps~=nil then P=assign({},r.defaultProps,P)end o:__validateProps(P)o.props=P local T=assign({},D.context)o._context=T o.state=assign({},o:__getDerivedState(o.props,{}))if o.init~=nil then o:init(o.props)assign(o.state,o:__getDerivedState(o.props,o.state))end D.context=o._context N.lifecyclePhase=ComponentLifecyclePhase.Render local V=o:render()N.lifecyclePhase=ComponentLifecyclePhase.ReconcileChildren a.updateVirtualNodeWithRenderResult(D,Y,V)if o.didMount~=nil then N.lifecyclePhase=ComponentLifecyclePhase.DidMount o:didMount()end if N.pendingState~=nil then o:__update(nil,nil)end N.lifecyclePhase=ComponentLifecyclePhase.Idle end

function Component:__mount(reconciler, virtualNode)
	if config.internalTypeChecks then
		internalAssert(Type.of(self) == Type.StatefulComponentClass, "Invalid use of `__mount`")
		internalAssert(Type.of(virtualNode) == Type.VirtualNode, "Expected arg #2 to be of type VirtualNode")
	end

	local currentElement = virtualNode.currentElement
	local hostParent = virtualNode.hostParent

	-- Contains all the information that we want to keep from consumers of
	-- Roact, or even other parts of the codebase like the reconciler.
	local internalData = {
		reconciler = reconciler,
		virtualNode = virtualNode,
		componentClass = self,
		lifecyclePhase = ComponentLifecyclePhase.Init,
	}

	local instance = {
		[Type] = Type.StatefulComponentInstance,
		[InternalData] = internalData,
	}

	setmetatable(instance, self)

	virtualNode.instance = instance

	local props = currentElement.props

	if self.defaultProps ~= nil then
		props = assign({}, self.defaultProps, props)
	end

	instance:__validateProps(props)

	instance.props = props

	local newContext = assign({}, virtualNode.context)
	instance._context = newContext

	instance.state = assign({}, instance:__getDerivedState(instance.props, {}))

	if instance.init ~= nil then
		instance:init(instance.props)
		assign(instance.state, instance:__getDerivedState(instance.props, instance.state))
	end

	-- It's possible for init() to redefine _context!
	virtualNode.context = instance._context

	internalData.lifecyclePhase = ComponentLifecyclePhase.Render
	local renderResult = instance:render()

	internalData.lifecyclePhase = ComponentLifecyclePhase.ReconcileChildren
	reconciler.updateVirtualNodeWithRenderResult(virtualNode, hostParent, renderResult)

	if instance.didMount ~= nil then
		internalData.lifecyclePhase = ComponentLifecyclePhase.DidMount
		instance:didMount()
	end

	if internalData.pendingState ~= nil then
		-- __update will handle pendingState, so we don't pass any new element or state
		instance:__update(nil, nil)
	end

	internalData.lifecyclePhase = ComponentLifecyclePhase.Idle
end
