function Component.__mount(N,P,T)if config.internalTypeChecks then internalAssert(Type.of(N)==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(T)==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 p=T.currentElement local b=T.hostParent local Q={reconciler=P;virtualNode=T;componentClass=N;lifecyclePhase=ComponentLifecyclePhase.Init}local d={[Type]=Type.StatefulComponentInstance;[InternalData]=Q}setmetatable(d,N)T.instance=d local k=p.props if N.defaultProps~=nil then k=assign({},N.defaultProps,k)end d:__validateProps(k)d.props=k local e=assign({},T.legacyContext)d._context=e d.state=assign({},d:__getDerivedState(d.props,{}))if d.init~=nil then d:init(d.props)assign(d.state,d:__getDerivedState(d.props,d.state))end T.legacyContext=d._context Q.lifecyclePhase=ComponentLifecyclePhase.Render local F=d:render()Q.lifecyclePhase=ComponentLifecyclePhase.ReconcileChildren P.updateVirtualNodeWithRenderResult(T,b,F)if d.didMount~=nil then Q.lifecyclePhase=ComponentLifecyclePhase.DidMount d:didMount()end if Q.pendingState~=nil then d:__update(nil,nil)end Q.lifecyclePhase=ComponentLifecyclePhase.Idle end
--[[
	An internal method used by the reconciler to construct a new component
	instance and attach it to the given virtualNode.
]]
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.legacyContext)
	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.legacyContext = 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
