Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation Mixin does not work #86

Closed
AllanOricil opened this issue Nov 9, 2020 · 5 comments
Closed

Navigation Mixin does not work #86

AllanOricil opened this issue Nov 9, 2020 · 5 comments

Comments

@AllanOricil
Copy link

AllanOricil commented Nov 9, 2020

Description

I opened this issue on the LWC repo, but it seems it belongs to this repo. salesforce/lwc#2073

I tried to use the navigaton example from the official docs, as it is, and it didn't work. On the local development server this example throws an error, while inside salesforce it does not throw anything.

https://developer.salesforce.com/docs/component-library/bundle/lightning-navigation/documentation

Steps to Reproduce

Create a LWC component with a button.

<template>
<button onclick={onClickNavigationButton}>Go to Account Home</button>
</template>
import { LightningElement } from "lwc";
import { NavigationMixin } from 'lightning/navigation';

export default class TestComponent extends LightningElement {

  onClickNavigationButton(){
    this[NavigationMixin.Navigate]({
      type: 'standard__objectPage',
      attributes: {
          objectApiName: 'Account',
          actionName: 'home',
      },
    });
  }
}

or

import { LightningElement } from "lwc";
import { NavigationMixin } from 'lightning/navigation';

export default class TestComponent extends LightningElement {

  onClickNavigationButton(){
    this[NavigationMixin.Navigate]({
      type: 'standard__objectPage',
      attributes: {
          objectApiName: 'Account',
          actionName: 'new',
      },
    });
  }
}

Expected Results

It should send the user to the account home page or new page

Actual Results

on Local development server it throws this exception

image

on Salesforce org it does not throw any error and it does not navigate the user to anywhere.

Browsers Affected

Tested only on Chrome Version 86.0.4240.111 (Official Build) (64-bit)

@msrivastav13
Copy link

NavigationMixin is not supported in the local development server. There are some modules the local development server does not support at this point!

@AllanOricil
Copy link
Author

@msrivastav13 where can I open an Issue regarding the other problem of the navigation mixin not working even inside Salesforce? I copied and pasted the example from the docs and it did not work.

@msrivastav13
Copy link

@AllanOricil I suggest you first use a platform like https://salesforce.stackexchange.com/ to post a query on what is not working with the code.

You can also open a support case with Salesforce Support!

@msrivastav13
Copy link

Looking at the code you have it wrong, where did you copy the code from?

Make sure your class extends NavigationMixin and passes LightningElement as shown below

export default class MyCustomElement extends NavigationMixin(LightningElement) {}

The above will work in Salesforce org but not in the local dev server as it is not supported yet!

@AllanOricil
Copy link
Author

@msrivastav13 thanks for noticing that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants