1. Scenario: Passing Data Between Components
You have two LWC components: ParentComponent and ChildComponent. The parent component needs to pass data to the child, and the child component should notify the parent when an action is performed.
Question: How would you pass data from the parent to the child component? How can the child notify the parent component when an event occurs?
Question : How to display account related contacts based on AccountId using the CustomEvent & dispatchEven in Salesforce lightning web component – LWC | how to display account related contacts based on AccountId in lwc
2. Scenario: Managing Large Datasets
Your LWC component needs to display a list of records from an object with potentially thousands of records.
Question: How would you efficiently fetch and display large datasets in LWC, ensuring smooth performance?
3. Scenario: Event Propagation
You have a deeply nested structure of LWCs (ParentComponent → ChildComponent → SubChildComponent). When a button is clicked in the SubChildComponent, a notification should be sent to ParentComponent.
Question: How would you handle event propagation in this scenario using custom events?
4. Scenario: Apex Calls
You are required to call an Apex method from LWC to retrieve data and handle success and error cases.
Question: How would you handle calling an Apex method in an LWC component and ensure proper error handling and loading indicators?
5. Scenario: Field Validation
You have an LWC form where the user enters values for different fields, including a date and email field.
Question: How would you handle client-side validation for this form before submitting the data to the server?
6. Scenario: Conditional Rendering
You need to show or hide certain parts of your LWC component based on user actions or data fetched from the server.
Question: How would you implement conditional rendering in LWC, and what would be the most efficient way to manage dynamic UI changes?
7. Scenario: Using Lightning Data Service
You need to fetch and modify a record using LWC without using Apex.
Question: How would you use Lightning Data Service in LWC to fetch, update, and save records?
8. Scenario: Pagination
You need to implement pagination for a list of records in an LWC component, with Next and Previous buttons to load more records.
Question: How would you implement pagination in LWC, ensuring the component remains performant with larger datasets?
9. Scenario: Third-Party API Integration
You need to integrate a third-party API in your LWC, fetching external data based on user input.
Question: How would you implement this integration while ensuring the user's input is validated, and the API call is secured?
10. Scenario: Accessibility
The component you are building will be used by people with disabilities, and you need to ensure it’s accessible.
Question: What steps would you take to ensure your LWC is accessible according to Salesforce best practices?
Comentarios