0

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??

4
  • 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
    – SFDCTashan
    Dec 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
    – SFDCTashan
    Dec 22, 2021 at 7:13

1 Answer 1

0

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).

1
  • Thnx again for your awesome help🙂🙂.. @sfdcfox... Much appreciated as this question was asked in interview
    – SFDCTashan
    Dec 22, 2021 at 7:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.