tc39 / proposal-signals

A proposal to add signals to JavaScript.
MIT License
3.43k stars 59 forks source link

React library that supports JavaScript Signals standard proposal #244

Open finom opened 3 weeks ago

finom commented 3 weeks ago

Thanks for the great proposal. I'm willing to try to apply signals into next React project I'm going to work on, and the most common library for that has very custom API and I would prefer to stick to a "standard" library for signals even if this proposal has only stage 1. Does anybody knows if there is a React library that supports this proposal?

NullVoxPopuli commented 3 weeks ago

to stick to a "standard" library for signals

What would that look like? React has no ergonomic/automatic way of retaining referential integrity, afaik

The other way I've seen Signals<->React integration work is via:

finom commented 3 weeks ago

@NullVoxPopuli that's correct. I was thinking of something that behaves similarly to effect and re-renders component when signal is triggered.

<div>{signal.get()}</div>

@preact/signals-react at this case requires to call useSignals() at the beginning of every component, and it can be avoided with a Babel plugin. Unfortunately, I couldn't yet figure out how to implement a hook like that and the only idea I have is to make a wrapper, but that is almost an anti-pattern today.