Salesforce Asked by Renato Oliveira on December 12, 2020
Currently I have a LWC that has a <slot>
inside of it to allow content between the tags. To test said component, I wanted to spin up a scratch org and quickly create a component. Since we can’t create LWC inside the console, I created an Aura component instead.
The markup is similar to this:
<aura:application extends="force:slds">
<div class="slds-box">
<c:tokenLocker recordId="5001A0000000000AAA"
passTokenToCallbackClass="true">
<h1>Hello world!</h1>
<p>Lorem ipsum, dolor</p>
</c:tokenLocker>
</div>
</aura:application>
When the LWC tokenLocker
displays the content, I simply get an empty div on screen, and no content is displayed at all.
I looked into the LWC documentation and found that in the section “Pass Markup into Slots” there’s this note right at the beginning of the document:
You can’t pass an Aura component into a slot.
I understand that it is not possible to pass an Aura component, but is this valid for simple HTML tags too?
In Aura, all HTML components are converted to aura:html components:
A meta component that represents all html elements. Any html found in your markup causes the creation of one of these.
In Aura, you can only pass in other LWC because of this limitation. In LWC, you can use both other LWC and HTML elements equally.
Correct answer by sfdcfox on December 12, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP