0

We are using custom Aura components in our Lightning Community and these components like most, respond to whomever is logged into the Lightning Community and populate themselves with relevant data. My question is when I am in Builder, those components are throwing errors because they do not have the info they need (logged in user info) because it's being viewed in the Builder. Is there a best-practice for not having those components throw errors in the Builder?enter image description here

1 Answer 1

2

That's in the documentation.

If components require interaction, provide an appropriate placeholder behavior in Lightning App Builder.

And

Don’t display a blank box. Think of how other sites work. For example, Facebook displays an outline of the feed before the actual feed items come back from the server. The outline improves the user’s perception of UI responsiveness.

And

Give your required properties default values. When a component that has required properties with no default values is added to the App Builder, it appears invalid, which is a poor user experience.

In summary, your code should be able anticipate having no data and respond accordingly.

What that specifically means for your code depends on what your code does, but in general, you should make sure you're validating inputs, checking for null/undefined properties, and so on, to ensure that the user sees something when interacting with your component in the builder.

From what I've seen, you can't reliably detect when you're in a builder environment, so it's probably best to assume that "no data" means you should show some default value.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .