initProps() — vue Function Reference
Architecture documentation for the initProps() function in state.ts from the vue codebase.
Entity Profile
Dependency Diagram
graph TD e399206d_b17d_5ac0_8caa_dab87591e37e["initProps()"] ecc8a243_a0d7_dbfe_d0d7_8a89943041cf["initProps()"] ecc8a243_a0d7_dbfe_d0d7_8a89943041cf -->|calls| e399206d_b17d_5ac0_8caa_dab87591e37e 7d6ab8ef_bd4c_49b2_1b21_a805de50af72["initState()"] 7d6ab8ef_bd4c_49b2_1b21_a805de50af72 -->|calls| e399206d_b17d_5ac0_8caa_dab87591e37e 604e5809_df6d_b3ac_e76f_cf1b5eeb9809["toggleObserving()"] e399206d_b17d_5ac0_8caa_dab87591e37e -->|calls| 604e5809_df6d_b3ac_e76f_cf1b5eeb9809 345b25ad_bb77_07cb_ecf5_8b82f12ddccd["defineReactive()"] e399206d_b17d_5ac0_8caa_dab87591e37e -->|calls| 345b25ad_bb77_07cb_ecf5_8b82f12ddccd 116cddf0_8d78_82e1_fbc7_5754697f785e["proxy()"] e399206d_b17d_5ac0_8caa_dab87591e37e -->|calls| 116cddf0_8d78_82e1_fbc7_5754697f785e style e399206d_b17d_5ac0_8caa_dab87591e37e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/core/instance/state.ts lines 72–126
function initProps(vm: Component, propsOptions: Object) {
const propsData = vm.$options.propsData || {}
const props = (vm._props = shallowReactive({}))
// cache prop keys so that future props updates can iterate using Array
// instead of dynamic object key enumeration.
const keys: string[] = (vm.$options._propKeys = [])
const isRoot = !vm.$parent
// root instance props should be converted
if (!isRoot) {
toggleObserving(false)
}
for (const key in propsOptions) {
keys.push(key)
const value = validateProp(key, propsOptions, propsData, vm)
/* istanbul ignore else */
if (__DEV__) {
const hyphenatedKey = hyphenate(key)
if (
isReservedAttribute(hyphenatedKey) ||
config.isReservedAttr(hyphenatedKey)
) {
warn(
`"${hyphenatedKey}" is a reserved attribute and cannot be used as component prop.`,
vm
)
}
defineReactive(
props,
key,
value,
() => {
if (!isRoot && !isUpdatingChildComponent) {
warn(
`Avoid mutating a prop directly since the value will be ` +
`overwritten whenever the parent component re-renders. ` +
`Instead, use a data or computed property based on the prop's ` +
`value. Prop being mutated: "${key}"`,
vm
)
}
},
true /* shallow */
)
} else {
defineReactive(props, key, value, undefined, true /* shallow */)
}
// static props are already proxied on the component's prototype
// during Vue.extend(). We only need to proxy props defined at
// instantiation here.
if (!(key in vm)) {
proxy(vm, `_props`, key)
}
}
toggleObserving(true)
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does initProps() do?
initProps() is a function in the vue codebase.
What does initProps() call?
initProps() calls 3 function(s): defineReactive, proxy, toggleObserving.
What calls initProps()?
initProps() is called by 2 function(s): initProps, initState.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free