initProps() — vue Function Reference
Architecture documentation for the initProps() function in state.ts from the vue codebase.
Entity Profile
Dependency Diagram
graph TD 7f0dd149_783c_767f_2b75_50290f62a377["initProps()"] 910d3a96_5984_cf85_40a3_47933bd75818["state.ts"] 7f0dd149_783c_767f_2b75_50290f62a377 -->|defined in| 910d3a96_5984_cf85_40a3_47933bd75818 c750fd7d_92c7_85b0_ab1c_c459424e4fb5["initProps()"] c750fd7d_92c7_85b0_ab1c_c459424e4fb5 -->|calls| 7f0dd149_783c_767f_2b75_50290f62a377 ceeb400a_fb7f_c638_1feb_8311db20c105["initState()"] ceeb400a_fb7f_c638_1feb_8311db20c105 -->|calls| 7f0dd149_783c_767f_2b75_50290f62a377 2bcc88b5_db8a_b047_2abd_7382948898ab["toggleObserving()"] 7f0dd149_783c_767f_2b75_50290f62a377 -->|calls| 2bcc88b5_db8a_b047_2abd_7382948898ab 772e5b8f_95bc_3463_fed7_f1034ba985e1["defineReactive()"] 7f0dd149_783c_767f_2b75_50290f62a377 -->|calls| 772e5b8f_95bc_3463_fed7_f1034ba985e1 cedf6e5d_ac48_bf6f_0fc6_d75bd1082b6e["proxy()"] 7f0dd149_783c_767f_2b75_50290f62a377 -->|calls| cedf6e5d_ac48_bf6f_0fc6_d75bd1082b6e style 7f0dd149_783c_767f_2b75_50290f62a377 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
Defined In
Called By
Source
Frequently Asked Questions
What does initProps() do?
initProps() is a function in the vue codebase, defined in src/core/instance/state.ts.
Where is initProps() defined?
initProps() is defined in src/core/instance/state.ts at line 72.
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