0

I have an Aura component with a lighting:datatable. I have a row action which opens another aura component but I'm trying to understand how I would open its LWC replacement. Here is what I currently have for the row action selected:

else if (action.name == 'view_gs_lwc') {
            var gslistLWC = {
                type: 'standard__component',
                attributes: {
                    componentName:'c:gslistLWC'
                },
                state: {
                    "c__Aid": row.Id
                    }
            };
            component.set("v.gslistLWC",gslistLWC);
            var navService = component.find("navService");
            var PageReference = component.get("v.gslistLWC");
            event.preventDefault();
            navService.navigate(PageReference);

Any help would be greatly appreciated! thanks!

  • As far as I'm aware, this code should work. Are you having any problems? – sfdcfox May 11 '20 at 20:11
  • I think the issue is probably that Lightning Web Components aren't URL addressable on their own, right? So you would need to nest it in an Aura component, Aura app, record detail page, or some other container to be able to link to it with an ID param passed in. Assuming you want the URL to change. Otherwise you could just use conditional rendering. – Matthew Souther May 11 '20 at 20:50
  • Thank you both for responding! The issue is that when I use what I have, I am sent to the following url: horizonblue--lightning.lightning.force.com/lightning/cmp/… Which is not valid for LWC. There does not seem to be a lot out there for navigation. I will try wrapping in Aura. Thanks so much!!!! – Frank May 12 '20 at 12:46
0

As I remembered you are not allowed to navigate directly from aura to LWC. But you have options, you can create an aura component as a wrapper for the LWC component or another option is to create a custom tab and navigate to the custom tab.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.