Empty tagged template strings seem to break reactivity

This issue has been tracked since 2023-01-02.

Repro: https://codesandbox.io/s/blissful-napier-k5gvjy?file=/src/index.js

I often use ternary operators for conditional rendering, something like

condition ? html`option 1` : html`option 2`

I noticed that when I don't have an "option 2", I can't simply write

condition ? html`option 1` : html``

because that will throw an error when the condition changes. If the condition doesn't change, it renders fine, no matter if the condition is true or false.

My initial workaround was simply filling the second option with a <br>; it fixed the issue and usually didn't cause any problems.
However, recently I also discovered that I can use null as well, and the parent template string will render it without a hiccup, so that's probably the preferred way. You might wanna add that to the docs somewhere?

Anyway, hope the repro helps and you can fix the bug, not that the empty template string solution should be encouraged or anything, but it certainly shouldn't break the whole application either (which it currently does).

I absolutely love arrow, it's been a great experience so far and I've even built and launched a full appliation, fully powered by arrow!
Keep up the good work, and let me know if you would like to hear more about my experience with it and my suggestions for useful additions :)

justin-schroeder wrote this answer on 2023-01-30

Great thanks for the feedback @Chaphasilor — and congrats on the app, thats really exciting. I'll tag this as a bug, we should probably return null in the case of an empty template to your point.

justin-schroeder wrote this answer on 2023-01-30

And yes I'd love to hear feedback from building an app with it. Maybe create a post under discussions so everyone can hear the good/bad/suggestions

Chaphasilor wrote this answer on 2023-01-30

Awesome, I'll write up something tomorrow!

Chaphasilor wrote this answer on 2023-01-30

@justin-schroeder created a discussion at #39 :)

More Details About Repo
Owner Name justin-schroeder
Repo Name arrow-js
Full Name justin-schroeder/arrow-js
Language TypeScript
Created Date 2022-11-08
Updated Date 2023-03-28
Star Count 1240
Watcher Count 21
Fork Count 22
Issue Count 7


Issue Title Created Date Updated Date