mergeProps deeply?

How deeply does merge props actually merge objects? Could I do?
const merged = mergeProps(
defaultsObj: {
key1: defaultValue1,
key2: defaultValue2
},
props
)
const merged = mergeProps(
defaultsObj: {
key1: defaultValue1,
key2: defaultValue2
},
props
)
where props has a props myObj with the values I want to default?
{
myObj:{
key1: value1,
key2: value2
}
}
{
myObj:{
key1: value1,
key2: value2
}
}
2 Replies
Alex Lohr
Alex Lohr2y ago
MergeProps does shallow merges. But props are only reactive on one level, so you could use something like mergeProps(defaults, deepMerge(defaults, props)); to do a deep merge.
SilentRhetoric
SilentRhetoricOP2y ago
Thanks, I think I can get the job done with shallow merge like this
const myObjWithDefaults = mergeProps(
{
key1: defaultValue1,
key2: defaultValue2
},
props.myObj
)
const myObjWithDefaults = mergeProps(
{
key1: defaultValue1,
key2: defaultValue2
},
props.myObj
)
Want results from more Discord servers?
Add your server