Skip to content

Commit

Permalink
feat: Upgrade React to v18
Browse files Browse the repository at this point in the history
- Remove unused enzyme-adapter-react-16 package
- Upgrade testing-library packages
  • Loading branch information
Merkur39 committed Oct 23, 2024
1 parent 0fa49ac commit e0779e2
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 370 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@
"devDependencies": {
"@babel/eslint-parser": "7.19.1",
"@babel/polyfill": "7.12.1",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "11.2.7",
"@testing-library/dom": "10.4.0",
"@testing-library/jest-dom": "6.6.2",
"@testing-library/react": "16.0.1",
"@testing-library/react-hooks": "8.0.1",
"@typescript-eslint/eslint-plugin": "5.54.0",
"@typescript-eslint/parser": "5.54.0",
Expand All @@ -50,7 +51,6 @@
"compare-versions": "5.0.1",
"cozy-scripts": "^8.3.0",
"cozy-tsconfig": "1.2.0",
"enzyme-adapter-react-16": "1.15.6",
"eslint": "8.35.0",
"eslint-config-cozy-app": "^6.1.0",
"eslint-config-prettier": "8.6.0",
Expand All @@ -67,7 +67,7 @@
"prop-types": "15.8.1",
"raw-loader": "3.1.0",
"react-hot-loader": "4.13.1",
"react-test-renderer": "16.14.0",
"react-test-renderer": "18.3.1",
"redux-mock-store": "1.5.4",
"stylint": "2.0.0",
"typescript": "4.9.5"
Expand Down Expand Up @@ -101,8 +101,8 @@
"lodash": "4.17.21",
"node-fetch": "2.6.1",
"pdf-lib": "1.17.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-input-mask": "3.0.0-alpha.2",
"react-inspector": "5.1.1",
"react-router-dom": "6.23.1",
Expand Down
3 changes: 1 addition & 2 deletions src/targets/browser/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable import/order */
import React from 'react'
import { render } from 'react-dom'

import 'cozy-ui/transpiled/react/stylesheet.css'
import 'cozy-ui/dist/cozy-ui.utils.min.css'
Expand All @@ -15,7 +14,7 @@ import { AppRouter } from 'src/components/AppRouter'
const init = () => {
const { root, ...rest } = setupApp()

render(<AppRouter {...rest} />, root)
root.render(<AppRouter {...rest} />)
}

registerServiceWorker()
Expand Down
6 changes: 4 additions & 2 deletions src/targets/browser/setupApp.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CaptureConsole } from '@sentry/integrations'
import * as Sentry from '@sentry/react'
import memoize from 'lodash/memoize'
import { createRoot } from 'react-dom/client'
import { makeClient } from 'src/targets/browser/makeClient'

import flag from 'cozy-flags'
Expand All @@ -16,8 +17,9 @@ const getDataOrDefault = (data, defaultData) =>
* Memoize this function in its own file so that it is correctly memoized
*/
const setupApp = memoize(() => {
const root = document.querySelector('[role=application]')
const locale = JSON.parse(root.dataset.cozy)?.locale
const container = document.querySelector('[role=application]')
const root = createRoot(container)
const locale = JSON.parse(container.dataset.cozy)?.locale
const lang = getDataOrDefault(locale, 'en')
const polyglot = initTranslation(lang, lang => require(`locales/${lang}`))
const client = makeClient()
Expand Down
Loading

0 comments on commit e0779e2

Please sign in to comment.