top | item 45258808

(no title)

jdkoeck | 5 months ago

Alas, that’s a common misconception! You’re confusing properties with attributes. Attributes are set through HTML and are stringly typed, but litjs properties can be any js value.

For instance, I have a project with a small web component that displays data from a duckdb wasm connection. The connection object is passed as a property and it works flawlessly.

discuss

order

chrismorgan|5 months ago

If you’re using it with something like React, passing attributes is easy, but setting properties is much harder, requiring using the escape hatches—I believe you’ll need useRef and useEffect, and a bit of care because it’s frightfully easy to do the wrong thing.

spankalee|5 months ago

No, React sets properties by default now. It was one of the last holdouts, but they finally fixed this in 19.