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

feat: upgrade app-runtime React version to v18 #1387

Merged
merged 8 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
8 changes: 4 additions & 4 deletions .github/workflows/dhis2-verify-lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- name: Build
run: yarn build

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: lib-build
path: |
Expand All @@ -77,7 +77,7 @@ jobs:
path: '**/node_modules'
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: lib-build

Expand All @@ -104,7 +104,7 @@ jobs:
path: '**/node_modules'
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: lib-build

Expand All @@ -123,7 +123,7 @@ jobs:
with:
node-version: 14.x

- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: lib-build

Expand Down
7 changes: 4 additions & 3 deletions examples/cra/src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react'
import ReactDOM from 'react-dom'
import { createRoot } from 'react-dom/client'
import App from './App'

it('renders without crashing', () => {
const div = document.createElement('div')
ReactDOM.render(<App />, div)
ReactDOM.unmountComponentAtNode(div)
const root = createRoot(div)
root.render(<App />, div)
root.unmount()
})
6 changes: 4 additions & 2 deletions examples/cra/src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from 'react'
import ReactDOM from 'react-dom'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App'
import * as serviceWorker from './serviceWorker'

ReactDOM.render(<App />, document.getElementById('root'))
const root = createRoot(document.getElementById('root'))

root.render(<App />)

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
Expand Down
1 change: 1 addition & 0 deletions examples/query-playground/src/components/Editor.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-unresolved */
import React from 'react'
import AceEditor from 'react-ace'

Expand Down
1 change: 1 addition & 0 deletions examples/query-playground/src/components/QueryTab.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/named
import { PropTypes } from '@dhis2/prop-types'
import React from 'react'
import { QueryEditor } from './QueryEditor'
Expand Down
1 change: 1 addition & 0 deletions examples/query-playground/src/components/TabControls.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import i18n from '@dhis2/d2-i18n'
// eslint-disable-next-line import/named
import { PropTypes } from '@dhis2/prop-types'
import {
Button,
Expand Down
19 changes: 8 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,16 @@
"services/*"
],
"devDependencies": {
"@dhis2/cli-app-scripts": "^10.2.0",
"@dhis2/cli-style": "^10.4.3",
"@dhis2/cli-app-scripts": "^12.0.0-alpha.21",
"@dhis2/cli-style": "10.4.3",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be a fixed version - the latest version that works with TypeScript doesn't work for the setup we have here with nested tsconfig, I will create a separate ticket and investigate it

"@dhis2/cli-utils-docsite": "^2.0.3",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^12.0.0",
"@testing-library/react-hooks": "^7.0.1",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.0.1",
"@types/jest": "^24.9.0",
"@types/lodash": "^4.14.171",
"@types/node": "^13.1.8",
"@types/react": "^16.9.18",
"@types/react-dom": "^16.9.5",
"@types/testing-library__dom": "^7.5.0",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@typescript-eslint/eslint-plugin": "^5.47.0",
"@typescript-eslint/parser": "^5.47.0",
"concurrently": "^5.0.2",
Expand All @@ -31,9 +29,8 @@
"idb": "^6.1.3",
"loop": "^3.3.4",
"prop-types": "^15.7.2",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-test-renderer": "^16.12",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"rimraf": "^3.0.0",
"typescript": "^4.0.5"
},
Expand Down
4 changes: 2 additions & 2 deletions runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
},
"peerDependencies": {
"prop-types": "^15.7.2",
"react": "^16.8.6",
"react-dom": "^16.8.6"
"react": "^16.8.6 || ^18",
"react-dom": "^16.8.6 || ^18"
},
"scripts": {
"build:types": "tsc --emitDeclarationOnly --outDir ./build/types",
Expand Down
4 changes: 2 additions & 2 deletions services/alerts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
],
"peerDependencies": {
"prop-types": "^15.7.2",
"react": "^16.8.6",
"react-dom": "^16.8.6"
"react": "^16.8.6 || ^18",
"react-dom": "^16.8.6 || ^18"
},
"scripts": {
"clean": "rimraf ./build/*",
Expand Down
2 changes: 1 addition & 1 deletion services/alerts/src/__tests__/integration.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { renderHook, act } from '@testing-library/react-hooks'
import { renderHook, act } from '@testing-library/react'
import React, { ReactNode } from 'react'
import { AlertsProvider, useAlerts, useAlert } from '../index'

Expand Down
2 changes: 1 addition & 1 deletion services/alerts/src/__tests__/useAlert.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { renderHook } from '@testing-library/react-hooks'
import { renderHook } from '@testing-library/react'
import React, { ReactNode } from 'react'
import { AlertsProvider, useAlert } from '../index'

Expand Down
2 changes: 1 addition & 1 deletion services/alerts/src/__tests__/useAlerts.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { renderHook } from '@testing-library/react-hooks'
import { renderHook } from '@testing-library/react'
import React, { ReactNode } from 'react'
import { AlertsProvider, useAlerts } from '../index'

Expand Down
2 changes: 1 addition & 1 deletion services/alerts/src/setupRTL.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '@testing-library/jest-dom/extend-expect'
import '@testing-library/jest-dom'

process.on('unhandledRejection', (err) => {
throw err
Expand Down
4 changes: 2 additions & 2 deletions services/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
],
"peerDependencies": {
"prop-types": "^15.7.2",
"react": "^16.8.6",
"react-dom": "^16.8.6"
"react": "^16.8.6 || ^18",
"react-dom": "^16.8.6 || ^18"
},
"scripts": {
"clean": "rimraf ./build/*",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { renderHook } from '@testing-library/react-hooks'
import { renderHook } from '@testing-library/react'
import React, { ReactNode } from 'react'
import { ConfigProvider, useTimeZoneConversion } from '../index'

Expand Down
2 changes: 1 addition & 1 deletion services/config/src/setupRTL.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '@testing-library/jest-dom/extend-expect'
import '@testing-library/jest-dom'

process.on('unhandledRejection', (err) => {
throw err
Expand Down
4 changes: 2 additions & 2 deletions services/data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"peerDependencies": {
"@dhis2/app-service-config": "3.10.4-alpha.1",
"prop-types": "^15.7.2",
"react": "^16.8",
"react-dom": "^16.8"
"react": "^16.8 || ^18",
"react-dom": "^16.8 || ^18"
},
"scripts": {
"build:types": "tsc --emitDeclarationOnly --outDir ./build/types",
Expand Down
24 changes: 11 additions & 13 deletions services/data/src/react/hooks/useDataMutation.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { renderHook, act } from '@testing-library/react-hooks'
import { renderHook, act, waitFor } from '@testing-library/react'
import * as React from 'react'
import { CreateMutation, UpdateMutation } from '../../engine/types/Mutation'
import { CustomDataProvider } from '../components/CustomDataProvider'
Expand All @@ -17,10 +17,9 @@ describe('useDataMutation', () => {
<CustomDataProvider data={data}>{children}</CustomDataProvider>
)

const { result, waitFor } = renderHook(
() => useDataMutation(mutation),
{ wrapper }
)
const { result } = renderHook(() => useDataMutation(mutation), {
wrapper,
})

const [mutate, beforeMutation] = result.current
expect(beforeMutation).toMatchObject({
Expand Down Expand Up @@ -61,7 +60,7 @@ describe('useDataMutation', () => {
<CustomDataProvider data={data}>{children}</CustomDataProvider>
)

const { result, waitFor } = renderHook(
const { result } = renderHook(
() => useDataMutation(mutation, { lazy: false }),
{ wrapper }
)
Expand Down Expand Up @@ -94,7 +93,7 @@ describe('useDataMutation', () => {
<CustomDataProvider data={data}>{children}</CustomDataProvider>
)

const { result, waitFor } = renderHook(
const { result } = renderHook(
() => useDataMutation(mutation, { onComplete }),
{ wrapper }
)
Expand Down Expand Up @@ -134,7 +133,7 @@ describe('useDataMutation', () => {
<CustomDataProvider data={data}>{children}</CustomDataProvider>
)

const { result, waitFor } = renderHook(
const { result } = renderHook(
() => useDataMutation(mutation, { onError }),
{ wrapper }
)
Expand Down Expand Up @@ -171,7 +170,7 @@ describe('useDataMutation', () => {
<CustomDataProvider data={data}>{children}</CustomDataProvider>
)

const { result, waitFor } = renderHook(
const { result } = renderHook(
() =>
useDataMutation(mutation, {
lazy: false,
Expand Down Expand Up @@ -270,10 +269,9 @@ describe('useDataMutation', () => {
<CustomDataProvider data={data}>{children}</CustomDataProvider>
)

const { result, waitFor } = renderHook(
() => useDataMutation(mutation),
{ wrapper }
)
const { result } = renderHook(() => useDataMutation(mutation), {
wrapper,
})

let mutatePromise
const [mutate] = result.current
Expand Down
Loading
Loading