MCPcopy
hub / github.com/vuejs/core / handleSetupResult

Function handleSetupResult

packages/runtime-core/src/component.ts:929–967  ·  view source on GitHub ↗
(
  instance: ComponentInternalInstance,
  setupResult: unknown,
  isSSR: boolean,
)

Source from the content-addressed store, hash-verified

927}
928
929export function handleSetupResult(
930 instance: ComponentInternalInstance,
931 setupResult: unknown,
932 isSSR: boolean,
933): void {
934 if (isFunction(setupResult)) {
935 // setup returned an inline render function
936 if (__SSR__ && (instance.type as ComponentOptions).__ssrInlineRender) {
937 // when the function's name is `ssrRender` (compiled by SFC inline mode),
938 // set it as ssrRender instead.
939 instance.ssrRender = setupResult
940 } else {
941 instance.render = setupResult as InternalRenderFunction
942 }
943 } else if (isObject(setupResult)) {
944 if (__DEV__ && isVNode(setupResult)) {
945 warn(
946 `setup() should not return VNodes directly - ` +
947 `return a render function instead.`,
948 )
949 }
950 // setup returned bindings.
951 // assuming a render function compiled from template is present.
952 if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
953 instance.devtoolsRawSetupState = setupResult
954 }
955 instance.setupState = proxyRefs(setupResult)
956 if (__DEV__) {
957 exposeSetupStateOnRenderContext(instance)
958 }
959 } else if (__DEV__ && setupResult !== undefined) {
960 warn(
961 `setup() should return an object. Received: ${
962 setupResult === null ? 'null' : typeof setupResult
963 }`,
964 )
965 }
966 finishComponentSetup(instance, isSSR)
967}
968
969type CompileFunction = (
970 template: string | object,

Callers 2

registerDepFunction · 0.90
setupStatefulComponentFunction · 0.85

Calls 7

isFunctionFunction · 0.90
isObjectFunction · 0.90
isVNodeFunction · 0.90
warnFunction · 0.90
proxyRefsFunction · 0.90
finishComponentSetupFunction · 0.85

Tested by

no test coverage detected