-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
Fix React adapter in SSR and when rerendering #355
Conversation
🦋 Changeset detectedLatest commit: eba0b93 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for preact-signals-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
b91bdec
to
c419f11
Compare
Size Change: +378 B (+1%) Total Size: 68.9 kB
ℹ️ View Unchanged
|
coverage && [ | ||
"istanbul", | ||
{ | ||
// TODO: Currently NodeJS tests always run against dist files. Should we | ||
// change this? | ||
// include: minify ? "**/dist/**/*.js" : "**/src/**/*.{js,jsx,ts,tsx}", | ||
}, | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: coverage isn't reported from this test run and I got tired and didn't set up running tests against source. If someone is feeling motivated and wants to do so, please do!
…y waiting until next frame to return from our fake act method
a58ac34
to
eba0b93
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damn, this was some research work I reckon :o
/* | ||
Below is a state machine definition for transitions between the various | ||
dispatchers in React's prod build. (It does not include dev time warning | ||
dispatchers which are just always ignored). | ||
|
||
ENTER and EXIT suffixes indicates whether this ReactCurrentDispatcher transition | ||
signals we are entering or exiting a component render, or if it doesn't signal a | ||
change in the component rendering lifecyle (NOOP). | ||
|
||
```js | ||
// Paste this into https://stately.ai/viz to visualize the state machine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty darn neat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of those rare PRs where the comments are so good that I came away feeling like I learned a thing or two.
Those things might be semi-cursed knowledge of React internals, but hey, knowledge is knowledge! 😅
Haha @rschristian definitely some cursed knowledge for sure 🧙🪄🔮 |
There are really hard job with researching weird react internals. Really appreciate. |
Updates the react adapter to handle SSR and components that call setState while rendering.
I've also added a suite of mocha test that run in NodeJS and use react-dom/server to validate our adapter works in that environment.
Note:
@preact/signals-react
package can not be lazily imported. It must be imported before you callReactDOM.render
,ReactDOM.hydrate
,renderToStaticMarkup
, etc.createElement
and related methods to handle passing signals as attributes to DOM elements.Fixes #350