preactjs / signals

Manage state with style in every framework
https://preactjs.com/blog/introducing-signals/
MIT License
3.63k stars 88 forks source link

Confusion on "Limitations" documentation #490

Closed lukexor closed 6 months ago

lukexor commented 6 months ago

The documentation indicates that signals are not supported in DOM "attributes" which I think really just means you have to use '.value' in them (since attributes have to be strings - but that's not really clear.

Also it mentions renderProps not being recommended/supported. I'm not sure if this Vite sandbox is just doing some other magic or what - but I also didn't set up any babel transforms so maybe some better clarification around this would help prevent confusion on adoption?

The below sandbox shows 4 different components for using signals in a variety of ways and tracks the component render count. I'd expect the last one to not work based on the documentation.

https://codesandbox.io/p/sandbox/cool-galileo-6kpfg7?file=%2Fsrc%2FApp.js%3A94%2C55

rschristian commented 6 months ago

The documentation indicates that signals are not supported in DOM "attributes" which I think really just means you have to use '.value' in them (since attributes have to be strings - but that's not really clear.

Once you use .value, that's no longer a signal. You're unwrapping it to its value.

Keep in mind you're also mismatching the docs to your version -- the "Limitations" section was added with v2, you're on (or your demo is, rather) v1.3.8.

lukexor commented 6 months ago

Ah thanks for clarifying! I didn't see any new release with the updated breaking changes so I wasn't even aware of the version mismatch and the change to removing the react internals in favor of a babel transform. Makes it much clearer now!

rschristian commented 6 months ago

I didn't see any new release with the updated breaking changes

488, I think our tooling might've stopped working. Sorry about that!