codeLive: How to Work with Dynamic Lightning Web Components
Вставка
- Опубліковано 6 жов 2024
- Dynamic Components introduced in the Winter ‘24 release let’s you create and instantiate components at runtime giving the ultimate flexibility to customize the user interface using LWC. In this live coding episode we will learn how to build LWC components using this feature.
Connect with Salesforce Developers:
Join the Community: salesforce.com...
Website: developer.sale...
LinkedIn: https:/linkedin.com/showcase/salesforcedevs/
X: x.com/salesfor...
Facebook: / salesforcedevs
I have used this in LWC OSS works great. Nice to have this on the Salesforce platform. Also its great that it supports non statically analysed imports
Thanks for the walkthrough. I was looking for something like this, and the timing is great! By the way, great video and audio quality!
that's amazing , man.. and the documentation is awesome! anyway, tks for the video bro!!
Interesting !!!! Nice Demo👏
It was helpful thanks, It would be nice if you can share the code for all three LWC that has been used in this.
Please find all the code in this branch github.com/trailheadapps/dreamhouse-lwc/tree/mo/dynamiclwc for now.
Note we plan to clean further and merge and make it part of the repo when unlocked packages are supported.
A simpler version is also cooking in lwc-recipes. Check here
github.com/trailheadapps/lwc-recipes/pull/897/files
Bit curious to know how graphQl was used to build those reactive components along with filter criteria. Have you recorded those videos if yes, can you please provide the link for those videos. Would be helpful to get to better at Lwc 😇
Building it live. You can watch our first session here ua-cam.com/video/PTYEzizzyW0/v-deo.html
I have also scheduled part 2 here - ua-cam.com/video/ddoHXjVg0AU/v-deo.html
can we use this dynamic LWC in Model popups? and pass the model results to parent component.
In theory you should be able to do it. But please let us know if you face any more issues.
Hii there can u pls tell me how to pass parameter from parent to child in this approach 😊
Mohith, You mentioned a point in your presentation. Dynamic components work only in Managed packages. I didn’t get this point. You created and deployed to org (May be a sandbox) as a component in working session. Will this not work if we deploy into prod org as the same way as other LWC components? Should this component be packaged into different namespace and deploy into Prod? Please clarify. Thank you very much
You can deploy them via metadata api using tools like Code Builder or Salesforce extensions. When packaged they are supported in Managed package and do not yet support unlocked package. We are fixing unlocked package issue in upcoming release.
Does GraphQL obey sharing permissions?
Im having a problem with custom event, when I set a child - parent (using dynamic lwc) custom event I dont recieve the parameters that I set.
Can you share the code example that is not working via stackexchange or the trailblazer community? Feel free to tag me on x or LinkedIn.
also getting error :Invalid dynamic components usage, lwc:component and lwc:is can only be used when dynamic components have been enabled. could you please help me out with this
is there a way we can use multiple dynamic components in a single lwc when i have a array of lwc incoming from a apex class can we create dynamic constructors also?
I am using Developer Edition and I have enabled Lightning Web Security. In VS code when I deploy the component, I am getting this error 'LWC1503: Dynamic imports are not allowed. (15:9)'
Check your meta xml to make sure it does have the dynamic components enabled.
@msrivastav13 is there a way also dynamically positioning and rendering those dynamic components? let's say I want 10 instances of the dynamic component one time and 20 instances the other time rendered in a certain order, so I cannot explicitly add them through to the html... I want to be able to construct the grid with all my components dynamically in JS and pass it through. I tried to construct using document.createElement() and pass a dynamically imported component in but it does not construct it correctly... I can find it all added to the page markup with inspector but it looks like it does not compile... Thanks!
Note you cannot construct dynamically. Please share more code so I can assist here. Tag me on the Trailblazer community.
Hi Mohith
Can we dynamically retrieve Custom Label in LWC like Apex?
We did address via apex. You can use the below help.salesforce.com/s/articleView?id=release-notes.rn_apex_system_label_methods.htm&release=244&type=5
With this is it possible render Custom Labels dynamically now?
We did address via apex.You can use the below help.salesforce.com/s/articleView?id=release-notes.rn_apex_system_label_methods.htm&release=244&type=5
Mohith sir can please share the code repository link for this demo
This is work in progress Niket. Most of our recipes use unlocked packages. We are adding support for unlocked packages in next release (Spring 24 #safeharbor) and then will push to the dreamhouse-lwc app.
is it possible to render multiple components?
In theory you should be able to have multiple of these. I have not tested it though. Please let us know if you face issues. Other issue I see making multiple of these is performance. Make sure to test for performance.