question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Functional component not rendering named slot (following #8871)

See original GitHub issue

Version

2.5.17

Reproduction link

https://codesandbox.io/s/p9mx85qpz0

Steps to reproduce

nothing in particular.

What is expected?

It should display Hello World

What is actually happening?

It displays Hello


Following https://github.com/vuejs/vue/issues/8871 I made App.vue non-functional:

If you make Child.vue non-functional it works: https://codesandbox.io/s/pw5lzx2w90

If you use default (not named) slots it works: https://codesandbox.io/s/04jrp3y4ln

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:2
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
murr4ycommented, Oct 1, 2018

Responded on the Vue Forum as well, is this maybe the same issue as in #7587?

It works by using a scoped slot: https://codesandbox.io/s/0p96w8o1pw

0reactions
posvacommented, Jul 2, 2019

In this specific scenario, the Parent component should be written like this:

  render(h, context) {
    context.data.scopedSlots = {
      username: () => h('span', {}, 'World')
    }
    return h(Child, context.data, [])
  },

I think we may need to adapt the functional component to allow passing a child with a slot attribute:

  render(h, context) {
    context.data.scopedSlots = {
      username: () => h('span', {}, 'World')
    }
    return h(Child, context.data, [
      h('span', { slot: 'username' }, 'World')
    ])
  },

@nickmessing I imagine the jsx plugin transforms into this because it has no way of knowing if Child is functional or not

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - How to pass content to a slot in render function ...
A component using template: MyButton.vue <template> <div> <slot name="left"></slot> <button> <slot v-bind:person="person"> <span>按钮</span> ...
Read more >
Slots - Vue.js
FancyButton renders slot content in its own template function FancyButton(slotContent) ... Slot content does not have access to the child component's data.
Read more >
How to fix - Slot invoked outside of the render function in vue 3
Find out how to solve the following error: "slot invoked outside of the render function" while developing Vue 3 components.
Read more >
PyCharm 2019.2.1 Release Notes | Knowledge Base
Bug, IDEA-218935, Gradle library imports broken after upgrade to 2019.2 ... parentOfType extension function fails when called from a plugin which bundles ...
Read more >
Shadow DOM slots, composition
Then our component should render it properly, as a nice menu with given ... slot name, they are appended into the slot, one...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found