Just so it doesn't get buried: we built Signals for Preact, but it works in React too - even the fancy granular text updates! Just import the @preact/signals-react package. github.com/preactjs/signa…
@_developit Oh wow, to think one day I would see elm in react. I'll definitely need to play around with this
@_developit Looking nice, is it already working with all the SSR stuff and suspense?
@_developit Kind of going behind React's back, aren't you? 😁
@_developit Glad you re-shared! I missed the initial launch!!
@_developit Will multiple instances of Counter maintain their own count values?
@_developit Does the granular updates work while combined with Context API ?
@_developit how is it able to do granular updates in react?
@_developit Nice. Maybe rename preact to postreact!
@_developit I love the interface of signals. Extremely simplistic and to the point. `signal, computed, effect, batch` all communicate exactly what they do in the context of a signal. I feel like we finally have a reactive-data-library that’s easy to use and much more simple than rxjs
@_developit Are signals hooks bound to react hooks rules ? Or did you manage to also get rid of them too?
@_developit since signals are not actual 'values' and seem to be just JSX. this has a lot of caveats, for example a signal without the `.value` is always truthy so you can't use it with ternaries for example.
@_developit Impressive! Are the performance benefits when applied to React similar to those of the Preact implementation?
@_developit 试了一下,React 版本只支持元数据比如 signal(0),但不支持 signal({ count: 0 })(嗯符合预期,这样的话,似乎用处不大 ... 要知道当时为了让 github.com/nanxiaobei/sol… 支持对象和数组,我可是费了老鼻子劲了,即使那样还是有些边界情况难以处理
@_developit sweet. One of the things Vue did was introduced ref "sugar" where you don't have to use .value
@_developit Nice! And what about unit tests for Counter component? We want an example🙂
@_developit So this is gonna get 100 million stars on github right? I've seen this, and the preact tweet, 5 times today, and it's been promoted on the computer programming topic. Signals is going to be the next state management standard?
@_developit If one was to build a userland Signal component as a wrapper, and manually use <Signal signal={signal} />, would it work without patching React? I mean, it would be worse DX, but patching react looks scary.
@_developit This looks cool Jason. Really great work. I think a blog post explaining how you’ve made this work in React might help ease React developers into trying it out. Without risking framework wars, I think the community is pretty averse to “magic” and this presents as magic.
@_developit Q: creating a new signal plus effect outside of a fn React component: const newSignal = value => { const sig = signal(value) effect(() => console.log(sig.value)) return sig } // comp const num = React.useMemo(() => newSignal(1), []) Seems to work! Any potential gotchas?
@_developit does this work with @reactnative ?
@_developit fortunately it only supports primitives, otherwise I would be scared to death 🥲