Skip to content

Commit

Permalink
Update to React 18
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Dec 14, 2023
1 parent d23f628 commit 42126e6
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"react/react-in-jsx-scope": "off",
"react-hooks/exhaustive-deps": "error",
"testing-library/render-result-naming-convention": "off",
"testing-library/no-render-in-setup": [
"testing-library/no-render-in-lifecycle": [
"error",
{
"allowTestingFrameworkSetupHook": "beforeEach"
Expand Down
27 changes: 13 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"openseadragon": "^2.4.2 || ^3.0.0 || ^4.0.0",
"prop-types": "^15.6.2",
"rdndmb-html5-to-touch": "^8.0.0",
"re-reselect": "^4.0.0",
"re-reselect": "^5.0.0",
"react-copy-to-clipboard": "^5.0.1",
"react-dnd": "^16.0.0",
"react-dnd-html5-backend": "^16.0.0",
Expand All @@ -66,17 +66,16 @@
"react-image": "^4.0.1",
"react-intersection-observer": "^9.0.0",
"react-mosaic-component": "^6.0.0",
"react-redux": "^7.1.0 || ^8.0.0",
"react-redux": "^8.0.0 || ^9.0.0",
"react-resize-observer": "^1.1.1",
"react-rnd": "^10.1",
"react-sizeme": "^2.6.7 || ^3.0.0",
"react-virtualized-auto-sizer": "^1.0.2",
"react-window": "^1.8.5",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.2",
"redux": "^5.0.0",
"redux-saga": "^1.1.3",
"redux-thunk": "^2.3.0",
"reselect": "^4.0.0",
"redux-thunk": "^3.1.0",
"reselect": "^5.0.0",
"stylis": "^4.3.0",
"stylis-plugin-rtl": "^2.1.1",
"url": "^0.11.0",
Expand All @@ -95,10 +94,10 @@
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.4",
"@testing-library/dom": "^9.2.0",
"@testing-library/jest-dom": "^6.1.5",
"@testing-library/react": "^12.1.5",
"@testing-library/react": "^14.1.2",
"@testing-library/user-event": "^14.4.3",
"@typescript-eslint/eslint-plugin": "^5.15.0",
"@typescript-eslint/parser": "^5.15.0",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"babel-jest": "^29.3.1",
"babel-loader": "^9.1.0",
"babel-plugin-lodash": "^3.3.4",
Expand All @@ -118,7 +117,7 @@
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-testing-library": "^5.10.2",
"eslint-plugin-testing-library": "^6.2.0",
"glob": "^10.3.0",
"http-server": "^14.1.0",
"jest": "^29.3.1",
Expand All @@ -127,9 +126,9 @@
"jest-puppeteer": "^9.0.2",
"jsdom": "^23.0.0",
"puppeteer": "^21.0.0",
"react": "^17.0.0",
"react": "^18.0.0",
"react-dnd-test-backend": "^16.0.1",
"react-dom": "^17.0.0",
"react-dom": "^18.0.0",
"react-refresh": "^0.14.0",
"redux-mock-store": "^1.5.1",
"redux-saga-test-plan": "^4.0.0-rc.3",
Expand All @@ -139,7 +138,7 @@
"webpack-dev-server": "^4.7.4"
},
"peerDependencies": {
"react": "^17.0.0",
"react-dom": "^17.0.0"
"react": "^18.0.0",
"react-dom": "^18.0.0"
}
}
13 changes: 7 additions & 6 deletions src/lib/MiradorViewer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ReactDOM from 'react-dom';
import { createRoot } from 'react-dom/client';
import { Provider } from 'react-redux';
import HotApp from '../components/App';
import {
Expand All @@ -20,10 +20,9 @@ class MiradorViewer {

if (config.id) {
this.container = document.getElementById(config.id);
config.id && ReactDOM.render(
this.render(),
this.container,
);
this.root = createRoot(this.container);

this.root.render(this.render());
}
}

Expand All @@ -42,7 +41,9 @@ class MiradorViewer {
* Cleanup method to unmount Mirador from the dom
*/
unmount() {
this.container && ReactDOM.unmountComponentAtNode(this.container);
if (!this.root) return;

this.root.unmount();
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/state/createStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// state normalisation
// (normalizer library)

import thunkMiddleware from 'redux-thunk';
import { thunk } from 'redux-thunk';
import createSagaMiddleware from 'redux-saga';
import { combineReducers, createStore, applyMiddleware } from 'redux';
import { composeWithDevTools } from '@redux-devtools/extension';
Expand All @@ -27,7 +27,7 @@ function configureStore(pluginReducers, pluginSagas = []) {
const store = createStore(
rootReducer,
composeWithDevTools(
applyMiddleware(thunkMiddleware, sagaMiddleware),
applyMiddleware(thunk, sagaMiddleware),
),
);

Expand Down
2 changes: 1 addition & 1 deletion src/state/selectors/manifests.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createSelector } from 'reselect';
import createCachedSelector from 're-reselect';
import { createCachedSelector } from 're-reselect';
import { PropertyValue, Utils, Resource } from 'manifesto.js';
import getThumbnail from '../../lib/ThumbnailFactory';
import asArray from '../../lib/asArray';
Expand Down
4 changes: 0 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ const baseConfig = mode => ({
}),
],
resolve: {
alias: {
'react/jsx-dev-runtime': 'react/jsx-dev-runtime.js',
'react/jsx-runtime': 'react/jsx-runtime.js',
},
extensions: ['.js'],
},
});
Expand Down

0 comments on commit 42126e6

Please sign in to comment.