-
Notifications
You must be signed in to change notification settings - Fork 16
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
feat: upgrade react to v18 #876
Conversation
b2da38a
to
b483ad9
Compare
9caf1bf
to
dd3283d
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.
LGTM, made a few comments - mainly asking if we should either:
- enforce ^18 as the peerdep for app-adapter (my current preference, moving forward and breaking at v12
- OR specify a union of
^16.8
and^18
for shell dependencies as well
Either is fine with me, and we can refine after it's in alpha if that's easier
adapter/package.json
Outdated
@@ -44,7 +43,7 @@ | |||
"classnames": "^2", | |||
"moment": "^2", | |||
"prop-types": "^15", | |||
"react": "^16.8", | |||
"react": "^16.8 || ^18", |
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.
Should this be just ^18
? If not, maybe all dependencies (including shell
, which isn't a peerdep) should use the union ^16.8 || ^18
? That would allow an app to specify ^16.8
and yarn would resolve to a single React version 16.8
since that would satisfy both. Otherwise if we're forcing a minimum version of 18 we could say ^18
and drop the ^16.8
in this peer dep?
Maybe easier to explain on a quick call or chat next week. It may be fine to leave this as-is, just curious what the reasoning is.
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.
yeah it should have been just ^18, updated it now - my reasoning was related to my question on why react is not a peer dependency of the shell. I thought the shell and adapter could live with either react@16 or 18, but that's not possible anyhow as the changes in the shell would only work in React@18 and it is the shell that provides react to consuming apps.
I also marked the commit as BREAKING CHANGE.
BREAKING CHANGE: require react version 18
dd3283d
to
e71e872
Compare
e71e872
to
7e5f03a
Compare
# [12.0.0-alpha.14](v12.0.0-alpha.13...v12.0.0-alpha.14) (2024-09-12) ### Features * upgrade react to v18 ([#876](#876)) ([77ecf10](77ecf10)) ### BREAKING CHANGES * require react version 18 * fix: pin react version to 18 * test: update test and test libraries for react 18
🎉 This PR is included in version 12.0.0-alpha.14 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Upgrades the platform and runtime to use react 18. Implements LIBS-630.
Testing setup
Clone this repo and checkout the
react-upgrade
branch, then we will use yalc to publish a new version of platform and runtime to use in our projects (follow the order described):app-platform/shell
Go to
app-platform/shell
(make sure you're onreact-upgrade
branch) then runyalc publish
app-platform/cli
Go to
app-platform/cli
and add a dependency toapp-shell
that we just published withyalc add @dhis2/[email protected]
Then edit the
files
section ofpackage.json
to include.yalc
, it will look like:Note
this is needed to make sure that the depdency of the dependency is also linked using yalc - see issue for context
app-runtime/runtime
Also clone the app-runtime
react-upgrade
, then go toapp-runtime/runtime
and runyalc publish
Test the upgrade of a project
Now navigate to a project to test the upgrade (I tested with
data-entry-app
,import-export
andapp-management
)yalc add @dhis2/[email protected]
to replace the version of cli-app-scripts with the locally published oneyalc add @dhis2/[email protected]
(this doesn't seem to be necessary as the peer depdendency is lenient and resolves to react version in the shell?)vite
, then run~/code/dhis/platform/app-platform/cli/bin/d2-app-scripts migrate js-to-jsx
(change to the correct path to where you have app-platform cloned)What to check?
The first sanity checks should be that when you run
yarn test
, you should see a log that it's using react@18and similarly you should see a console.log in the running app
These are your sanity checks that you're running the correct version after all this depdendency madness
Then:
yarn why react
and ensure it resolves react@18yarn start
and do a sanity check that the app worksyarn build
- you will likely need to runnpx yarn-deduplicate
beforeyarn build
works (you will get an error about duplication in yarn.lock)ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it’s running React 17
Notes
Checklist / Known issues
RTL shell is brokenfalse alarmSupport for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead
- needs a separate update to UIOther Questions / Discussions
react
at the top level@dhis2/ui-root
but that's never used directly, right?Shouldn't the react depdendency in app-shell be a peer depdendency?Screenshots