Already wire adapter was there in LWC i.e. @wire annotation to display the records,so can we do the same thing (display the records) through LWC constructor also? If yes, then why @wire feature was introduced in LWC??
-
I'm not at all clear on what you are asking. What does it mean to "display records through LWC constructor"? Please edit your post to provide clarity and concrete examples.– David Reed ♦Dec 22, 2021 at 5:34
-
Yeah.. Did that– SFDCTashanDec 22, 2021 at 5:36
-
Your edit did not add any more information on what you are trying to do or ask. Please review How to Ask and help center, take a step back, and try again to explain the technical problem or question you are struggling with.– David Reed ♦Dec 22, 2021 at 5:39
-
I think I got the answer through sfdcfox... No more edits required– SFDCTashanDec 22, 2021 at 7:13
1 Answer
You can't call out to the server in the constructor()
or connectedCallback()
synchronously. They will be delayed, as asynchronous calls, until at least the first renderedCallback()
cycle. As such, @wire
methods provide the same results with less code (potentially just one line of code).
-
Thnx again for your awesome help🙂🙂.. @sfdcfox... Much appreciated as this question was asked in interview Dec 22, 2021 at 7:14