Description
The optimization only apply when there is a function call
count()>1 && Date.now() // Memo count()> 1 ? Date.now() : "B" // Memo count()> 1 ? "A" : "B" // No Memobut interestingly does not memo when using a getter ( 🐛 )
https://playground.solidjs.com/anonymous/6afa6081-5fa7-4ca6-b690-fcb92dbbe2e0count()>1 ? props.a : props.b
I think originally I was looking at this for components.. and since components were just function calls that's how I set the rule. To be fair it's a single option switch to have it wrap getters. I think it makes sense to wrap getters as well. This was probably overlooked initially and just stayed.
Originally posted by @mizulu in #2479
created this issue so this is not lost in the other issue.
Note:
the issue originally refer to boolean condition passed in props.
but this optimization also exists in JSX
This will get a memo on the condition
<b>{count()<=3 ? props.f1() : props.f2() }</b>
but this will not
<b>{count()<=3 ? props.g1 : props.g2 }</b>
there might be same expectations here too.