0

Aura if and else provides conditional rendering. But this is what happening in my case. I have 2 version of my UI one is desktop and other is mobile. Which gets rendered using aura if and else :

aura if: true == my mobile flag Show mobile UI aura else attribute Show desktop UI

Now when the page loads final result is correct. But when the page is loading I can see else condition UI getting displayed even though am not able to access the screen and then finally based on the flag correct UI loads.

Now the flaw here is at the time when UI is loading and it is showing else UI regardless of flag, if i disconnect from network and make the page stop right there I will be able to see my else UI regardless of whatever value of flag is. Since there are links on the page which the user is not allowed when he is loading from mobile. But in case of network failure at the time of screen loads he may have access to those.

Does anyone has faced this kind of behavior ?

1
  • 2
    Hi and welcome to SFSE. Please edit your question to show the basic structure of your markup as that way community members understand how you are using aura:if/else together and may have insight into what is happening more easily. – Phil W Dec 13 '20 at 16:17
0

You need a loading aura:if on the outside:

<aura:if isTrue="{!v.loading}">
  <lightning:spinner />
  <aura:set attribute="else">
    <aura:if isTrue="{!v.isMobile}">
      <c:mobileView />
      <aura:set attribute="else">
        <c:desktopView />
      </aura:set>
    </aura:if>
  </aura:set>
</aura:if>
1
  • Thanks for the reply, this was not working for me. I got the reason why it was loading desktop first earlier. Since I have set the attribute default value as true for desktop and false for mobile. I have made both of them false now. So until and unless it is not calculating the correct value for both none of the UI will be loaded. – user3012372 Dec 14 '20 at 14:29

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.