Questions tagged [lightning-web-components]
This tag is for questions related to JavaScript, CSS, or Markup when used in the Lightning Web Component (LWC) programming model, or for questions of interoperability between LWC and the original Aura-based lightning components.
8,920
questions
53
votes
8
answers
38k
views
Target inner elements of standard Lightning Web Components with CSS
Say we have a LWC with the following template in a component named example:
<template>
<lightning-textarea class="test"></lightning-textarea>
</template>
And some css to ...
47
votes
6
answers
96k
views
Uncaught TypeError: 'set' on proxy: trap returned falsish for property Name
Am not doing anything fancy, just trying to update a field on Contact in JS of LWC but getting this exception.
Uncaught TypeError: 'set' on proxy: trap returned falsish for property 'Name'
throws at ...
43
votes
6
answers
137k
views
Force refresh view in LWC
In Aura, we can do
$A.get('e.force:refreshView').fire();
to cause standard components to update.
How can we do an equivalent in LWC because sfdx refuses to publish .js code with $A in it saying ...
40
votes
5
answers
52k
views
Expression Functions for Lightning Web Components
How can expression functions similar to Visualforce and Lightning Aura Components be achieved within lightning web components?
For example, <template if:true={index % 5 == 0}><br></...
39
votes
3
answers
7k
views
How to turn boxcarring OFF for LWC imperative apex method calls?
We are running in a blocking performance issue on a page that we built using Lightning Web Components.
Our page has many LWC components, each calling various apex methods via an imperative method ...
37
votes
1
answer
6k
views
What are Lightning Web Components
Salesforce has just announced a new feature, Lightning Web Components. What is this? What does it have to do with Lightning Components and the Lightning Component Framework?
33
votes
6
answers
40k
views
Dynamic component creation in Lightning Web Components
Is there any way to create and add lightning web components dynamically in the component tree ? I mean the equivalent one in Aura is $A.createComponent().
The usual Web Components can be dynamically ...
33
votes
1
answer
23k
views
LWC setting properties in connectedCallback()
This blog is talking about things we can do with lwc connectedCallback method. It seems to contradict itself with a certain point so I am trying to make sure.
They say that we can set property values ...
31
votes
2
answers
64k
views
async/await functions in LWC
Assume I have an LWC component and Apex Aura controller:
/* AccountController.cls */
public with sharing class AccountController {
@AuraEnabled
public static List<Account> getAll() {
...
31
votes
3
answers
12k
views
Lightning Web Components - Benefits and Support
Salesforce announced Lightning Web Components in Dec. 2018. In comparison to the existing Aura Framework:
What are the benefits of using Lightning Web Components? / How much faster are they?
Where ...
30
votes
4
answers
69k
views
Track Input value in LWC
What
I'm trying to bind a controller variable with lightning-input's value. For instance myVar
So far
Following all examples and documentation of LWC I'm able to do so by using the onchange method ...
29
votes
4
answers
30k
views
LWC as QuickAction in Salesforce
I have made a quick action in lightning web component and want ot make that compponent available for quick action. I havenot found any guide or documentation regarding this. Can you please suggest on ...
27
votes
1
answer
28k
views
LWC navigation error: "this[f.NavigationMixin.Navigate] is not a function"
When attempting to use the Lightning navigation service in my component's base class (.js), I get the following error when functionally testing in the UI:
this[f.NavigationMixin.Navigate] is not a ...
25
votes
3
answers
8k
views
Not able to render dynamic Lightning Web Component
I am refering Play Ground to render dynamic component in LWC. But it is giving error createElement is not defined.
Have any one idea how to render dynamic component. Alternative of createComponent ...
24
votes
3
answers
111k
views
How do you define an element with an ID attribute using LWC?
I'd like to be able to link to certain portions of my page using URL fragments, eg:
<h3 id="overview">Overview</h3>
...
<a href="#overview">Go to Overview</a>
Unfortunately ...
23
votes
3
answers
29k
views
Can't get refreshApex() to work in lwc
I'm not able to get refreshApex() working in an lwc. I've read the docs here -- scroll to the bottom. Here are the key elements of the js file:
import { LightningElement, track, api, wire } from 'lwc'...
23
votes
1
answer
5k
views
Array.find and Array.findIndex has worst performance in LWC Lightning Locker
For the component chain like below:
<container>
<parent>
<child>
<grand-child>
Pass an Array from container to all the way down to grand-child. This is ...
21
votes
5
answers
42k
views
Add Lightning Web Component to Lightning Tab
I am trying to figure out how to add a Lightning Web Component to a Lightning tab. I have it on the Home Page, but I would like it to be on its own tab. I feel like there should be an option to ...
21
votes
2
answers
61k
views
Javscript onload in LWC
i have a requirement to call a javascript method on load of the template.
is there any way to do that in LWC?
21
votes
4
answers
57k
views
Lightning Web Component for table rows and cells
I'm trying to build a LWC that renders a complex table-based UI. It needs to have distinct rows and columns with dynamically-determined colspans - a real table. It's for assigning lodging, and each ...
21
votes
2
answers
3k
views
Boxcaring is removed from LWC components?
This question is the extension of How to turn boxcarring OFF for LWC imperative apex method calls?.
While taking into consideration for LWC implementations, that we do not have equivalent of action....
20
votes
12
answers
49k
views
recordId is undefined in LWC quick action component
I have created an LWC component for quick action and also defined the @api recordId inside that. But the recordId is undefined in the component when logged. Seems like it is not being passed to the ...
20
votes
2
answers
22k
views
Using unescape HTML in lightning web component
I am currently having an issue to show the content fetched from salesforce database to UI. The data is stored in HTML form and I want it to show on UI using LWC without escaping HTML. Previously we ...
20
votes
2
answers
41k
views
How do I invoke a value change handler in LWC?
Is there a way in LWC to declare an attribute value change handler like there was in Aura? My use case is that I have a pager component which has 2 @api properties. When either of the @api values ...
20
votes
1
answer
14k
views
Chain wire methods together in Lightning Web Components
According to the documentation here in order to retrieve a list of picklist values for an object we need to pass in a Record Type Id which can be retrieved using the getObjectInfo method.
The issue is ...
20
votes
2
answers
40k
views
How to target LWC by name attribute?
During a submit I'd like to intercept the event and run some custom validation on the input values. Here is a simplified template of what I'd like to do:
<template>
<lightning-input type="...
20
votes
3
answers
4k
views
Not being able to reference packaged custom LWCs from other LWCs outside the package
This restriction referenced from Distribute Components on AppExchange:
A custom Lightning web component can’t access a Lightning web
component or module in a custom namespace. It can access ...
19
votes
3
answers
34k
views
Is it possible to navigate to a Visualforce page from an LWC with parameters and community compatible
The LWC framework includes the NavigationMixin.Navigate functionality that can be used to obtain URLs or perform navigation to generated URLs. This supports a number of different page types, as ...
19
votes
3
answers
25k
views
LWC Handling Multiple Dependents @Wire methods
How we handle dependent wire in LWC?
For example :
@wire(getObjectInfo, { objectApiName: OPP_OBJECT })
objectInfo;
@wire(getPicklistValues, {
recordTypeId: '$objectInfo.data....
19
votes
1
answer
4k
views
Lightning Web Components Open Source with Lightning Design System (lwc with slds)
I am trying to local development with Lightning Web Component. The https://lwc.dev works good and I want to also add the Lightning Design System style but I am getting errors.
I have installed the ...
19
votes
1
answer
4k
views
Canvas App (or equivalent) for Lightning Web Components
We are currently using the force:canvasApp lightning component to embed an external site securely into Salesforce.
The Spring '19 release is introducing Lightning Web Components as the future of ...
18
votes
2
answers
25k
views
Order of execution of @wire in lwc
I know that @wire methods are always executed once our component is loaded. I want to dig deep into this and want to understand the order of execution with respect to the component's life cycle. When ...
18
votes
1
answer
22k
views
Get RecordId in LWC From Community Page
I'm trying to make a component in my community be able to pull in the record Id.
I followed the information in this question: LWC Community recordId undefined
And this documentation: https://...
17
votes
2
answers
6k
views
CSS animation in LWC not working
I'm unable to get a simple css fade-in-out text animation to work in LWC. The text displays on the page okay, but it does not fade in/out like expected. It seems as though the keyframes are getting ...
17
votes
4
answers
8k
views
Feasibility to import entire LWC classes to access @api methods
I'm looking to modularize my LWC without having to embed them in the template. Ideally, would this kind of pattern be feasible? I'm not sure if it's my lack of ES6 knowledge (modules) or that LWC ...
16
votes
5
answers
37k
views
Lightning Web Components - Not available in app builder
I'm developing a lightning web component with org based development and I'm finding that the component isn't available in the app builder, despite (as far as I can tell) making it available in the ...
16
votes
1
answer
49k
views
connectedcallback vs renderedcallback in lightning web component
I'm new to Salesforce LWC. I'm trying to understand the LWC component life cycle methods. But it is a bit difficult to understand. Can any give a simple explanation about connectedcallback() and ...
16
votes
2
answers
14k
views
How to show hyperlink in LWC toast
I have created a LWC that executes a call to the controller and shows a toast message if the call fails:
const event = new ShowToastEvent({
title: "Error",
...
16
votes
4
answers
30k
views
Get records in Lightning web components without APEX
import { LightningElement, track, api, wire } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
const FIELDS_SOLICITUD = [
'DCABM_obj_solicitudABM__c.DCABM_fld_aplicacionSolicitud__c'...
15
votes
2
answers
67k
views
Hyperlink record name LWC datatable
I am trying to fetch List of sobjects and show them in data table. I want to add a hyperlink to record name. I am using @wired property to dynamically get records depending on the search term.
my test....
15
votes
3
answers
14k
views
Handle click outside element in LWC
I am looking to create a custom lookup component using Lightning Web Components. I want to be able to detect when the user is clicking outside of the element so that I can close the dialog and/or ...
15
votes
2
answers
2k
views
Modularize (existing) LWC for reuse and flexible distribution
I am currently breaking a monolithic 1GP Managed package into more modular 2GP packages.
While doing this I also want to decompose chunky LWC components in a way so they can be reused more flexibly ...
15
votes
5
answers
6k
views
What is involved in moving over to Lightning Web Components?
I read:
Aura Components, leveraging its own component model, templates, and modular development programming model.
Lightning Web Components, built on top of the web standards breakthroughs of the ...
15
votes
1
answer
14k
views
how to pass parameter to apex method which is called imperatively from lightning web component
I'm working on one LWC and facing issue while passing parameters to an apex method which I am calling imperatively on selection of a record in datatable. I'm able to get selected recordid in JS ...
14
votes
6
answers
20k
views
lightning-datatable - remove header actions
Is it possible to remove the header (column) actions completely from lightning-datatable?
It seems that no matter what I do I'm still stuck with Wrap Text and Clip Text actions.
UPDATE
Adding more ...
14
votes
3
answers
37k
views
NoErrorObjectAvailable Script error
I have a LWC that is used in different orgs. In one of them, when I dispatch an event like:
this.dispatchEvent( new CustomEvent( 'press' ));
I am getting the [NoErrorObjectAvailable] Script error in ...
14
votes
3
answers
11k
views
How to refresh wired service getRecord manually?
Please note that this is not duplicate of LWC Force Refresh Wire getRecord - this question and answer specifically speaks about changes in front-end/UI and capturing that in front-end BUT LDS cannot ...
14
votes
1
answer
4k
views
LWC and complex parameters
I am trying to pass a list of objects to Apex from an LWC controller, and it looks like the Apex controller is getting the right sized list, but nothing is populated. Does anybody have any idea of ...
14
votes
1
answer
14k
views
Log to console in a Lightning Web Component
I am attempting to write a Lightning Web Component, but continually run into errors in my Javascript that I can't debug.
I've been trying to log my error but when I put console.log() anywhere in the ...
14
votes
4
answers
5k
views
Testing LWC with multiple @wire getRecord calls with Jest
I thought this would be straight-forward, but it turns out to be a complete nightmare. Found no help on google, in the lwc-recipes or documentation.
Here's my issue: I have a LWC that makes multiple ...