proposal-signals icon indicating copy to clipboard operation
proposal-signals copied to clipboard

React library that supports JavaScript Signals standard proposal

Open finom opened this issue 1 year ago • 5 comments

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?

finom avatar Oct 28 '24 13:10 finom

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:

  • https://github.com/dai-shi/use-signals

NullVoxPopuli avatar Oct 28 '24 13:10 NullVoxPopuli

@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.

finom avatar Oct 28 '24 14:10 finom

@jkup any comment about the issue completion?

finom avatar Jul 14 '25 15:07 finom

@finom Sorry! I've just been going through older issues. Reopening now! What do you think would be the best outcome for this? I was thinking we could:

  1. Explain why adding Signals support to react is difficult on the README
  2. Add links to the README for current React+Signals libraries like https://github.com/dai-shi/use-signals or https://signia.tldraw.dev/?
  3. Bring up React integration at one of our community calls to see if anyone has ideas on how we could better support integration?

jkup avatar Jul 14 '25 22:07 jkup

@jkup I think the best outcome would be either a library, or an article on how to build such library if it's small. But as far as I understand from your comment it's not really doable, is that correct? If there is going to be a widely used library that allows to utilize the "standard signals" in practice, the standard itself is going to be pushed forward significantly IMO.

finom avatar Jul 15 '25 20:07 finom