-
Notifications
You must be signed in to change notification settings - Fork 257
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
[question] How can we access slot props of scoped slots #452
Comments
Hi! Here you have some examples on how to destructure props from a scoped slot: It is true, though, that we might want to feature an example on docs, possibly on |
Thank you soooooooo much! That provides a ton of info that helped. |
@yakobe would you be able to make a PR adding some more info on this to the docs? |
Sure! I'll take a look and try to knock something together. It's just the md files in this repo huh? Is there a detailed procedure or just make a PR. Short question:Those tests are great because they show multiple scenarios that help. I don't want to bloat the docs with too many examples (maybe 1 or 2). What do you think about adding links to test cases in the docs? They show real code examples and are automatically expanded with new scenarios as they arise. It might also help with contributions as more people would be aware of the tests scenarios and what they relate to. |
Just update the md files in this repo! I think a few examples in the docs + some links to source code is fine. |
How do we access it with a plain render function? |
Please share the component and test you are having problems with @adi518. |
You can check it out here: https://github.com/adi518/vue-facebook-login/blob/next/packages/vue-facebook-login-component-next/tests/unit/FacebookLogin.spec.js#L142 Previously (Vue 2) I could do this: https://github.com/adi518/vue-facebook-login/blob/next/packages/vue-facebook-login-component/tests/unit/FacebookLogin.spec.js#L122 I described my use case here: #577 |
Neat, I had no idea you could do that (even in VTU v1). Hidden feature - it's definitely not documented, as far as I know. It would be good to support that here, too. I made an issue to track it: #578. I have no idea if/how to implement this off the top of my head. |
I was too, surprised that hack actually worked, but it's not pretty, so I hope we can go back to the template literal when it's fixed. I did try all of the suggestions in #452 (comment), but it made the test throw ambiguous warnings, see below: console.warn ../../node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:40
[Vue warn]: Property undefined was accessed during render but is not defined on instance.
at <Anonymous key=0 idle=true working=true ... >
at <FacebookLoginButton scope= {
idle: true,
working: true,
hasError: true,
connected: true,
disconnected: true
} ref="VTU_COMPONENT" >
at <VTUROOT> |
Oh - I thought you wanted to use a render function. Do we still have a bug with template literals? |
Yes, unless I write them the way it is now, I'm getting the warning above, although the snapshot is fine. |
Ok. Maybe related: #549 If you'd like to open a new issue with your exact reproduction, that's the best way to ensure this doesn't get forgotten - since we are discussing in a closed issue, it's easy for this to get swept under the rug. |
In VTU 1 it was possible to access the variables passed into slots using the
scopedSlots
mounting option (https://vue-test-utils.vuejs.org/api/options.html#scopedslots)In VTU 2 this is no longer an option and scoped slots are combined with the
slots
mounting option. However it does not seem to be possible to access the the slot props.listItem
is passed in to the template via slots like this (as described in the docs):It used to be possible to do something like this:
Hewever, i dont seem to be able to access the
listItem
and the documentation does not cover how it should be done. Is it still possible and, if so, what is the syntax?Many thanks
The text was updated successfully, but these errors were encountered: