-
-
Notifications
You must be signed in to change notification settings - Fork 99
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-signals with next.js 14 #466
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
The new 2.0.0 version of @preact/signals-react provides a |
I've implemented swc plugin how to use |
The @preact/signals-react documentation mention two ways:
|
For next JS you need to use SWC plugin |
Why not simply use the useSignal() hook to instantiate a signal |
Consider a scenario below The above has been referred from the NPM documentation but, small difference is they referred signals as Not until I referred the signals as |
Reading signal |
So even when I am creating a signal using the |
Also then how using only |
Also can you explain me the phrase |
Conceptually react integration works like this. Every component wrapped with try finally to start tracking and finish it in finally block. // start tracking reading of signals
const store = _useSignalsImplementation(1);
try {
return renderYourComponent(props);
} finally {
// stop tracking reading of signals
store.f();
} If you're using // start tracking and will stop tracking on new microtask
useSignals()
// code
return jsx |
You can think about it like every component code wrapped in |
|
This comment was marked as off-topic.
This comment was marked as off-topic.
When I use signal() and return signal.value, it never gets updated on further signal.value updates. The only way to show it and update it is to just return signal, but in that case, if I have a complex object, such as User, I can't just do signal.username, I must do signal.value.username (which would not work as I said above, and as a bonus, if you return signal.value.something on a object, it always shows undefined) |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
@OpenSource03 Please provide an example. That goes for everyone else too, without reproductions, we cannot help. This thread has gotten pretty off topic so I'm going to close it out as answered. |
Work for me huge thanks :) |
Just curious if anyone has successfully gotten signals to work with next.js 14? I get this error when I try:
Unhandled Runtime Error
TypeError: Cannot read properties of undefined (reading 'length')
Call Stack
areHookInputsEqual
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (10921:0)
updateEffectImpl
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (12303:0)
updateEffect
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (12323:0)
updateSyncExternalStore
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (11802:0)
Object.useSyncExternalStore
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (13448:0)
useSyncExternalStore
node_modules/next/dist/compiled/react/cjs/react.development.js (1797:0)
P
node_modules/@preact/signals-react/dist/signals.module.js (1:2148)
Object.set [as current]
node_modules/@preact/signals-react/dist/signals.module.js (1:2976)
renderWithHooks
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (10968:0)
updateFunctionComponent
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (16163:0)
beginWork$1
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (18359:0)
beginWork
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (26741:0)
performUnitOfWork
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (25587:0)
workLoopConcurrent
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (25573:0)
renderRootConcurrent
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (25529:0)
performConcurrentWorkOnRoot
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (24382:0)
workLoop
node_modules/next/dist/compiled/scheduler/cjs/scheduler.development.js (261:0)
flushWork
node_modules/next/dist/compiled/scheduler/cjs/scheduler.development.js (230:0)
MessagePort.performWorkUntilDeadline
node_modules/next/dist/compiled/scheduler/cjs/scheduler.development.js (534:0)
The text was updated successfully, but these errors were encountered: