we are working on LWC Open Source and to navigate to the new component, currently we are using if:true with a boolean value which is not appropriate for a long run. Is there any other way to achieve this either by the help of routing or dynamic creation of components in LWC Open Source?
1 Answer
Here’s how you can create components dynamically. It’s just the standard way how you’d instantiate an LWC.
Note that you have to clean up things afterwards.
https://github.com/pmdartus/rcast/blob/master/src/client/modules/rcast/app/app.js#L91
The example also shows how to use that with a custom routing package.
https://github.com/pmdartus/rcast/blob/master/src/client/modules/rcast/app/app.js#L30
-
I get a 404 when trying to access the github links in your answer. Please update them if you know the correct repository location or add code snippets if not. Commented Apr 4, 2020 at 11:51