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

Upgrade to React 18 #1659

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wip! blindly upgrade a bunch of things with problematic peer deps on …
…react

All of these had peer deps on react that evaluated to <18.  Upgrades for
most were available, often major version bumps so they may come with
breaking changes.  A couple things were not available and we need to
switch to alternatives.  Our calling code for libraries has not been
updated, so it's unlikely to compile or run.  But npm is now happy!
  • Loading branch information
tsibley authored and jameshadfield committed Feb 7, 2024
commit 83ff183602945a34e9d7c63c93406162f9b227ad
1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ module.exports = function babelConfig(api) {
"lodash"
];
if (api.env("development")) {
// XXX FIXME react-18
plugins.push(["react-hot-loader/babel", { safetyNet: false }]);
}
if (process.env.BABEL_INCLUDE_TIMING_FUNCTIONS === "false") {
571 changes: 187 additions & 384 deletions package-lock.json

Large diffs are not rendered by default.

17 changes: 8 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -47,7 +47,6 @@
"@babel/preset-env": "^7.9.6",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.21.0",
"@hot-loader/react-dom": "^16.13.0",
"@reduxjs/toolkit": "^1.9.7",
"argparse": "^1.0.10",
"babel-loader": "^8.0.4",
@@ -97,18 +96,18 @@
"prop-types": "^15.6.0",
"query-string": "^4.2.3",
"react": "^18.2.0",
"react-collapsible": "^2.8.4",
"react-collapsible": "^2.10.0",
"react-dom": "^18.2.0",
"react-ga": "^2.2.0",
"react-helmet": "^5.2.1",
"react-hot-loader": "^4.8.4",
"react-ga": "^3.3.1",
"react-helmet": "^6.1.0",
"react-i18next": "^11.15.6",
"react-icons": "^3.9.0",
"react-redux": "^7.2.6",
"react-select": "^5.2.2",
"react-redux": "^7.2.9",
"react-select": "^5.8.0",
"react-side-effect": "^2.1.2",
"react-tooltip": "^4.2.10",
"react-transition-group": "^1.2.1",
"react-virtualized": "^9.22.3",
"react-transition-group": "^4.4.5",
"react-window": "^1.8.10",
"regenerator-runtime": "^0.13.5",
"style-loader": "^0.13.2",
"styled-components": "^4.0.3",
6 changes: 6 additions & 0 deletions src/components/controls/virtualizedMenuList.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import React, { useLayoutEffect, useRef } from "react";
// XXX FIXME react-18: react-virtualized has peer dep on react ^16 and won't
// get updates; need to switch to react-window
// <https://github.com/bvaughn/react-window#how-is-react-window-different-from-react-virtualized>
import { List } from "react-virtualized/dist/es/List";
import { CellMeasurer, CellMeasurerCache } from "react-virtualized/dist/es/CellMeasurer";
import { isEqual } from "lodash";
@@ -15,6 +18,7 @@ const VirtualizedMenuList = ({ children, maxHeight, focusedOption }) => {
const listRef = useRef(null);
const options = useRef(null);
const cache = useRef(
// XXX FIXME react-18
new CellMeasurerCache({
fixedWidth: true,
defaultHeight: DEFAULT_ROW_HEIGHT
@@ -58,6 +62,7 @@ const VirtualizedMenuList = ({ children, maxHeight, focusedOption }) => {
* component via the cache
*/
const rowRenderer = ({ index, key, parent, style }) => (
// XXX FIXME react-18
<CellMeasurer
cache={cache.current}
columnIndex={0}
@@ -85,6 +90,7 @@ const VirtualizedMenuList = ({ children, maxHeight, focusedOption }) => {
};

return (
// XXX FIXME react-18
<List
ref={listRef}
height={calcListHeight()}
4 changes: 4 additions & 0 deletions src/components/notifications/notifications.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from "react";
import PropTypes from 'prop-types';
import { connect } from "react-redux";
// XXX FIXME react-18: migrate from v1 → v2
// <https://github.com/reactjs/react-transition-group/blob/master/Migration.md>
import { CSSTransitionGroup } from "react-transition-group";
import { REMOVE_NOTIFICATION } from "../../actions/types";

@@ -100,6 +102,8 @@ class Notifications extends React.Component {
return null;
}
return (
// XXX FIXME react-18: migrate from v1 → v2
// <https://github.com/reactjs/react-transition-group/blob/master/Migration.md>
<CSSTransitionGroup className="notifications"
transitionName="notification"
transitionEnterTimeout={500}
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import "core-js";
import "regenerator-runtime";
import "css.escape";
/* L I B R A R I E S */
// XXX FIXME react-18
import "react-hot-loader";
import React from "react";
import ReactDOM from "react-dom";
1 change: 1 addition & 0 deletions src/root.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { lazy, Suspense } from 'react';
import { connect } from "react-redux";
// XXX FIXME react-18
import { hot } from 'react-hot-loader/root';
import Monitor from "./components/framework/monitor";
import DatasetLoader from "./components/datasetLoader";
10 changes: 7 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -17,8 +17,11 @@ const generateConfig = ({extensionPath, devMode=false, customOutputPath, analyze
// Format is either "libName" or "libName:libPath"
const coreDeps = [
"react",
"react-hot-loader",
"react-dom:@hot-loader/react-dom",
// XXX FIXME react-18: react-hot-loader won't support react 18; must switch to
// react-refresh slash builtin support hooks? unclear without more digging.
// see <https://github.com/facebook/react/issues/16604>
//"react-hot-loader",
//"react-dom:@hot-loader/react-dom",
"regenerator-runtime",
"core-js",
"styled-components"
@@ -131,7 +134,8 @@ const generateConfig = ({extensionPath, devMode=false, customOutputPath, analyze
"regenerator-runtime",
"whatwg-fetch",
"style-loader",
"@hot-loader/react-dom",
// XXX FIXME react-18
//"@hot-loader/react-dom",
"react(-(redux|select|helmet|i18next))?",
"leaflet",
"redux",