-
Notifications
You must be signed in to change notification settings - Fork 393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable else on the template after using if:true | false #2503
Comments
I don't remember all the details about the then/else situation. Maybe @diervo remembers. Few things that come to mind:
|
@nolanlawson is this implemented by this release? https://developer.salesforce.com/blogs/2023/01/lwc-enhancements-for-developers-learn-moar-spring-23 |
Other questions: Why prepending conditionals with the word "lwc:"? |
@AllanOricil Yep, as the blog post mentions, this is shipping in Spring '23.
This was discussed in the RFC. After weighing the pros and cons, we decided to create a brand-new set of directives for this. BTW we welcome comments from the community on our RFCs; you can follow that repo to keep up-to-date on what we're planning. 🙂 I agree that deprecating the existing
In general, it's to make it clear which directives are native to the browser and which were added by LWC. (Historically we weren't always consistent about this, e.g. the |
Closing as this is solved by #2985 |
Is your feature request related to a problem? Please describe.
At the moment, to conditionally show something in the template, developers have to write something like this:
and because getters are not memoized (#243) lwc calls
showA
twice, which is a problem that has already been adressed and has a proposed fix (#2300).But, considering that the memoization problem is fixed, you could also improve performance and DX by enabling developers to do write this:
I think performance would be increased because the template engine wouldn't even evaluate the "else" when "if:true" is resolved to true. In the current way, I think even with memoization the engine would still waste time evaluating the "if:false" condition, right?
As for DX, it is much easier to read the example above. Vue does that and everyone loves it.
Describe the solution you'd like
Change this
to this
Describe alternatives you've considered
Currently developers have to do this
Additional context
N/A
The text was updated successfully, but these errors were encountered: