I have a parent component that houses a form where there's a birthday component within the form and the birthday component has two different components within it. I'm tasked with implementing these two main components (the form parent component and the birthday component) to pass props and emit changes up and confused as to what those props should be.
My question around this is, how do I know what to pass as props and emit up? It seems the most nested child component has defined props, the parent component has defined props and the birthday component is the middle-man between the two. How do I determine what to use as props??
For a visual of what I'm working with:
Parent Form Component
^ data v
Birthday Component
^ data v
Select Options && Text Input Components
The props from each component is:
// Parent Form Component
props: {
currentSlide: {
type: String,
required: true
},
totalSlides: {
type: String,
required: true
},
nextRoute: {
type: Object,
required: true
}
}
Here's the birthday component within the Parent Form Component:
<Birthday
:value="$v.form.dob.model" // was informed this was passing a prop from a peer
:show-errors="fieldErrors"
describedBy="edit-dob-error"
@input="v => setAge(v)"
ref="dobInput"
/>
Props for the Select Options Component:
props: {
options: {
type: Array,
require: true
},
header: {
type: String,
required: false
},
value: {
type: String,
required: false
},
dateSelected: {
type: Boolean,
required: false
},
narrow: {
type: Boolean,
required: false
},
textInput: {
type: Boolean,
required: false
},
year: {
type: [String, Number],
required: false
}
}
Objectively, I would like to return (or rather $emit) a string in return 'yyyy-mm-dd' to the Parent Form Component to get passed through the existing validation methods we have, but for the life of me, I can't seem to grasp how to return the value I want.