Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React library that supports JavaScript Signals standard proposal #244

Open
finom opened this issue Oct 28, 2024 · 2 comments
Open

React library that supports JavaScript Signals standard proposal #244

finom opened this issue Oct 28, 2024 · 2 comments

Comments

@finom
Copy link

finom commented Oct 28, 2024

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
Copy link
Collaborator

NullVoxPopuli commented Oct 28, 2024

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
Copy link
Author

finom commented Oct 28, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants