-
Notifications
You must be signed in to change notification settings - Fork 758
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
Update react to 18 #1290
Update react to 18 #1290
Conversation
ba1e257
to
0c4b30d
Compare
9647f75
to
643d444
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.
Great 👍🏾
Except for the format of the changelog, everything looks good.
I approve to prevent block for merge.
Update:
When I started the review, we had a passing CI! So I removed the review.
CHANGELOG.md
Outdated
### Breaking Changes | ||
- Remove support & testing for Webpacker 3/4. | ||
- Add support & testing for Shakapacker v6 | ||
## Breaking Changes | ||
### Removed | ||
- Support & testing for Webpacker 3/4. | ||
- WebpackManifestContainer, which searched for assets in the webpack manifest | ||
### Added | ||
- Support & testing for Shakapacker v6 | ||
- SeparateServerBundleContainer, which expects a single server bundle file & does not use the webpack manifest at all. | ||
### Usage | ||
- Requires separate compilations for server & client bundles (see [Webpack config](https://github.com/reactjs/react-rails/tree/master/test/dummy/config/webpack)) | ||
- Replaces WebpackManifestContainer, which searched for assets in the webpack manifest, with SeparateServerBundleContainer, which expects a single server bundle file & does not use the webpack manifest at all. | ||
- All in one PR! #1274 | ||
### Dependencies |
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.
If we want to follow our convention, we need to add each change in the appropriate category and then add the PR number. It is fine to repeat the PR number in multiple entries.
This way, we won't have any line saying "All in one PR..."
Also since this is a changelog for the release, we shouldn't both say add support for Shakapacker 6 and also add support for Shakapacker 7. We basically drop support for Shakapacker 6. We jump to Shakapacker 7.
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.
Great 👍🏾
CHANGELOG.md
Outdated
## Breaking Changes | ||
### Removed | ||
- Support & testing for Webpacker & Shakapacker v6. #1274 | ||
- WebpackManifestContainer, which searched for assets in the webpack manifest. #1274 |
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.
Add
- Requires upgrading to Shakapacker v7
Does it?
or only the generator?
can a shakapacker v6 or webpacker v5 project update?
can you use without any shakapacker? and only sprockets?
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.
Yes, Shakapacker v7 is currently required because we have code that calls Shakapacker.config
If you want, we could change the constant back to Webpacker
for backwards compatibility.
@ahangarha was this tested with React 17 from shakapacker? Sprockets will only having react 18 |
d571dcd
to
1b6b7ad
Compare
react_ujs/index.js
Outdated
@@ -143,7 +147,7 @@ var ReactRailsUJS = { | |||
|
|||
for (var i = 0; i < nodes.length; ++i) { | |||
var node = nodes[i]; | |||
ReactDOM.unmountComponentAtNode(node); | |||
ReactDOM.createRoot ? this.unmountRoot(node) : ReactDOM.unmountComponentAtNode(node); |
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.
use an if statement
react_ujs/index.js
Outdated
@@ -131,6 +132,9 @@ var ReactRailsUJS = { | |||
} else { | |||
const root = createReactRootLike(node) | |||
component = root.render(component); | |||
if(ReactDOM.createRoot) { |
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.
make variable
// Means React 18 or greater
const supportsRootsApi = typeof(ReactDOM.createRoot) !== "undefined"
@@ -155,6 +163,15 @@ var ReactRailsUJS = { | |||
detectEvents(this) | |||
}, | |||
|
|||
unmountRoot: function(node) { |
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.
Comment
// only for supportsRootsApi
react_ujs/index.js
Outdated
@@ -155,6 +163,15 @@ var ReactRailsUJS = { | |||
detectEvents(this) | |||
}, | |||
|
|||
unmountRoot: function(node) { | |||
var targetRoots = this.roots.filter(function(rootElement) {return rootElement["node"] && (rootElement["node"] === node)}) |
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.
we should have at least eslint -- this formatting is bad...
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.
I agree.
Once I tried to add eslint configuration, but the result was much worse than adding Rubocop. Then I stopped it.
react_ujs/index.js
Outdated
@@ -7,7 +7,7 @@ var constructorFromGlobal = require("./src/getConstructor/fromGlobal") | |||
var constructorFromRequireContext = require("./src/getConstructor/fromRequireContext") | |||
var constructorFromRequireContextWithGlobalFallback = require("./src/getConstructor/fromRequireContextWithGlobalFallback") | |||
var constructorFromRequireContextsWithGlobalFallback = require("./src/getConstructor/fromRequireContextsWithGlobalFallback") | |||
const { supportsHydration, reactHydrate, createReactRootLike } = require("./src/renderHelpers") | |||
const { supportsHydration, reactHydrate, createReactRootLike, supportsRootsApi } = require("./src/renderHelpers") |
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.
why mix var and const?
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.
requires should be const
react_ujs/index.js
Outdated
rootElement["root"].unmount(); | ||
rootElement["root"] = null; | ||
rootElement["node"] = null; | ||
return undefined; |
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.
eslint passing? weird
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.
We don't check linter!
@@ -1,3 +1,10 @@ | |||
// polyfill TextEncoder & TextDecoder onto `util` b/c `node-util` polyfill doesn't include them | |||
// https://github.com/browserify/node-util/issues/46 |
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.
comment on b/c react 18
CHANGELOG.md
Outdated
|
||
## Breaking Changes | ||
### Removed | ||
- Support & testing for Webpacker & Shakapacker v6. #1274 |
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.
not a breaking change
just remove ^^^ line
CHANGELOG.md
Outdated
### Added | ||
- Add support & testing for Shakapacker 7 #1274 and #1285 | ||
|
||
- Support & testing for Shakapacker v7. #1274 and #1285 |
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.
Updated not added that gem tests now use shakapacker v7 and not ...
CHANGELOG.md
Outdated
- Replaces WebpackManifestContainer, which searched for assets in the webpack manifest, with SeparateServerBundleContainer, which expects a single server bundle file & does not use the webpack manifest at all. #1274 | ||
|
||
## Breaking Changes | ||
### Removed |
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.
only put what's breaking under breaking
don't have subtopics
only provide list of what updates an upgrader needs to do
CHANGELOG.md
Outdated
#### Changed | ||
- Requires separate compilations for server & client bundles (see [Webpack config](https://github.com/reactjs/react-rails/tree/master/test/dummy/config/webpack)). #1274 |
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.
emphasize that this is a potentially breaking change if NOT using sprockets and using SSR. Clarity! and that goes under the breaking changes.
CI failing also |
df72cdc
to
8d4cf3d
Compare
8d4cf3d
to
48c21f3
Compare
@@ -170,7 +193,6 @@ ReactRailsUJS.handleUnmount = function(e) { | |||
if (e && e.target) { | |||
target = e.target; | |||
} | |||
ReactRailsUJS.unmountComponents(target); |
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.
With this change, ReactRailsUJS.handleUnmount is now a no-op. That doesn't seem intentional ?
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 change upgrades React-Rails' embedded react to v18.2.0 & uses node polyfill plugin & fast-text-encoder for SSR text encoding (
react-dom.server
requires a reference to aTextEncoder
constructor).Update documentation