-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vnode props can not seem to be updated from parent #1082
Comments
Solution: You can should directly return children. In vuejs/rfcs#154.
The props with |
Sorry, I don't quite get it. I don't expect/rely on anything being fallthrough though. All I know is Is there a solution without returning children directly because I can't skip |
sorry.I dont have another solution for this. |
Thanks for the help so far. I feel like somehow the modified vnodes( In other words, there seems no way to modify indirect child nodes in vue, which kind of makes sense. I didn't intend to use the extra component either, I was trying to do everything in SFC
I got a warning in the console:
I guess I'll stick to the render function |
Update, I had some luck with SFC finally. It turns out I can totally get rid of |
First, as you have noticed, you don't really need the Note that even with the fixes, you should never directly mutate a vnode in Vue 3: vnodes should be considered immutable (as they may be a compiler-hoisted vnode). Instead, use const Tabs = (props, {emit, slots}) => {
const children = slots.default ? slots.default() : []
returnh('div', children.map(vnode => {
return cloneVNode(vnode, {
// ...props
})
})
} |
@yyx990803 thanks for the reply. I know this ticket is closed but I do have a follow up question please. Suppose now I need to access
In both cases, the I've updated to the latest version |
Not sure if you guys would still get notification after a ticket is closed. Just on the safe side, I opened a new ticket: #1186 |
Version
3.0.0-beta.4
Reproduction link
https://codepen.io/lzhoucs/pen/rNOzpZa
Steps to reproduce
What is expected?
The tab clicked should render its
active
prop astrue
What is actually happening?
The tab renders its initial
active
prop valuefalse
and never re-renders after being clickedI am using a functional component
Tabs
to update its childrenTab
before handing it over to_Tabs
because I don't know how to do the same directly in_Tabs
:Using other approaches such as scoped slots might work however that's less ideal because the user who uses this component has to do extra work besides below:
In my opinion, handling tab click and activate/deactivate tab should be the tab(s) component's job as a library, and the user only provides
v-model
for initial state and gets notified when selected is updated.According to vuejs/vue#4766 (comment), this should work in vue 2 but I didn't try.
I also tried the
cloneVNode
approach as oppose to mutate the vnode directly, but it didn't work for meThe text was updated successfully, but these errors were encountered: