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 all 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
4 changes: 2 additions & 2 deletions .github/workflows/dhis2-deploy-netlify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
if: "!github.event.push.repository.fork && github.actor != 'dependabot[bot]'"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v4
with:
node-version: 14.x
node-version: 20.x

- uses: c-hive/gha-yarn-cache@v1
- run: yarn install --frozen-lockfile
Expand Down
28 changes: 14 additions & 14 deletions .github/workflows/dhis2-verify-lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v4
with:
node-version: 14.x
node-version: 20.x

- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
Expand All @@ -40,9 +40,9 @@ jobs:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v4
with:
node-version: 14.x
node-version: 20.x

- uses: actions/cache@v2
id: yarn-cache
Expand All @@ -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 @@ -67,17 +67,17 @@ jobs:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v4
with:
node-version: 14.x
node-version: 20.x

- uses: actions/cache@v2
id: yarn-cache
with:
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 @@ -94,17 +94,17 @@ jobs:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v4
with:
node-version: 14.x
node-version: 20.x

- uses: actions/cache@v2
id: yarn-cache
with:
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 @@ -119,11 +119,11 @@ jobs:
- uses: actions/checkout@v2
with:
token: ${{env.GH_TOKEN}}
- uses: actions/setup-node@v1
- uses: actions/setup-node@v4
with:
node-version: 14.x
node-version: 20.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
32 changes: 16 additions & 16 deletions examples/cra/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1054,32 +1054,32 @@
integrity sha512-ij4wRiunFfaJxjB0BdrYHIH8FxBJpOwNPhhAcunlmPdXudL1WQV1qoP9un6JsEBAgQH+7UXyyjh0g7jTxXK6tg==

"@dhis2/app-runtime@file:../../runtime":
version "3.10.0-alpha.2"
version "3.10.4-alpha.1"
dependencies:
"@dhis2/app-service-alerts" "3.10.0-alpha.2"
"@dhis2/app-service-config" "3.10.0-alpha.2"
"@dhis2/app-service-data" "3.10.0-alpha.2"
"@dhis2/app-service-offline" "3.10.0-alpha.2"
"@dhis2/app-service-plugin" "3.10.0-alpha.2"
"@dhis2/app-service-alerts" "3.10.4-alpha.1"
"@dhis2/app-service-config" "3.10.4-alpha.1"
"@dhis2/app-service-data" "3.10.4-alpha.1"
"@dhis2/app-service-offline" "3.10.4-alpha.1"
"@dhis2/app-service-plugin" "3.10.4-alpha.1"

"@dhis2/app-service-alerts@3.10.0-alpha.2", "@dhis2/app-service-alerts@file:../../services/alerts":
version "3.10.0-alpha.2"
"@dhis2/app-service-alerts@3.10.4-alpha.1", "@dhis2/app-service-alerts@file:../../services/alerts":
version "3.10.4-alpha.1"

"@dhis2/app-service-config@3.10.0-alpha.2", "@dhis2/app-service-config@file:../../services/config":
version "3.10.0-alpha.2"
"@dhis2/app-service-config@3.10.4-alpha.1", "@dhis2/app-service-config@file:../../services/config":
version "3.10.4-alpha.1"

"@dhis2/app-service-data@3.10.0-alpha.2", "@dhis2/app-service-data@file:../../services/data":
version "3.10.0-alpha.2"
"@dhis2/app-service-data@3.10.4-alpha.1", "@dhis2/app-service-data@file:../../services/data":
version "3.10.4-alpha.1"
dependencies:
react-query "^3.13.11"

"@dhis2/app-service-offline@3.10.0-alpha.2", "@dhis2/app-service-offline@file:../../services/offline":
version "3.10.0-alpha.2"
"@dhis2/app-service-offline@3.10.4-alpha.1", "@dhis2/app-service-offline@file:../../services/offline":
version "3.10.4-alpha.1"
dependencies:
lodash "^4.17.21"

"@dhis2/app-service-plugin@3.10.0-alpha.2", "@dhis2/app-service-plugin@file:../../services/plugin":
version "3.10.0-alpha.2"
"@dhis2/app-service-plugin@3.10.4-alpha.1", "@dhis2/app-service-plugin@file:../../services/plugin":
version "3.10.4-alpha.1"
dependencies:
post-robot "^10.0.46"

Expand Down
32 changes: 16 additions & 16 deletions examples/query-playground/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1800,32 +1800,32 @@
"@dhis2/app-service-offline" "3.8.0"

"@dhis2/app-runtime@^2.2.2", "@dhis2/app-runtime@file:../../runtime":
version "3.10.0-alpha.2"
version "3.10.4-alpha.1"
dependencies:
"@dhis2/app-service-alerts" "3.10.0-alpha.2"
"@dhis2/app-service-config" "3.10.0-alpha.2"
"@dhis2/app-service-data" "3.10.0-alpha.2"
"@dhis2/app-service-offline" "3.10.0-alpha.2"
"@dhis2/app-service-plugin" "3.10.0-alpha.2"
"@dhis2/app-service-alerts" "3.10.4-alpha.1"
"@dhis2/app-service-config" "3.10.4-alpha.1"
"@dhis2/app-service-data" "3.10.4-alpha.1"
"@dhis2/app-service-offline" "3.10.4-alpha.1"
"@dhis2/app-service-plugin" "3.10.4-alpha.1"

"@dhis2/app-service-alerts@3.10.0-alpha.2", "@dhis2/app-service-alerts@3.8.0", "@dhis2/app-service-alerts@file:../../services/alerts":
version "3.10.0-alpha.2"
"@dhis2/app-service-alerts@3.10.4-alpha.1", "@dhis2/app-service-alerts@3.8.0", "@dhis2/app-service-alerts@file:../../services/alerts":
version "3.10.4-alpha.1"

"@dhis2/app-service-config@3.10.0-alpha.2", "@dhis2/app-service-config@3.8.0", "@dhis2/app-service-config@file:../../services/config":
version "3.10.0-alpha.2"
"@dhis2/app-service-config@3.10.4-alpha.1", "@dhis2/app-service-config@3.8.0", "@dhis2/app-service-config@file:../../services/config":
version "3.10.4-alpha.1"

"@dhis2/app-service-data@3.10.0-alpha.2", "@dhis2/app-service-data@3.8.0", "@dhis2/app-service-data@file:../../services/data":
version "3.10.0-alpha.2"
"@dhis2/app-service-data@3.10.4-alpha.1", "@dhis2/app-service-data@3.8.0", "@dhis2/app-service-data@file:../../services/data":
version "3.10.4-alpha.1"
dependencies:
react-query "^3.13.11"

"@dhis2/app-service-offline@3.10.0-alpha.2", "@dhis2/app-service-offline@3.8.0", "@dhis2/app-service-offline@file:../../services/offline":
version "3.10.0-alpha.2"
"@dhis2/app-service-offline@3.10.4-alpha.1", "@dhis2/app-service-offline@3.8.0", "@dhis2/app-service-offline@file:../../services/offline":
version "3.10.4-alpha.1"
dependencies:
lodash "^4.17.21"

"@dhis2/app-service-plugin@3.10.0-alpha.2", "@dhis2/app-service-plugin@file:../../services/plugin":
version "3.10.0-alpha.2"
"@dhis2/app-service-plugin@3.10.4-alpha.1", "@dhis2/app-service-plugin@file:../../services/plugin":
version "3.10.4-alpha.1"
dependencies:
post-robot "^10.0.46"

Expand Down
26 changes: 14 additions & 12 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.24",
"@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 All @@ -51,12 +48,17 @@
"start": "yarn build && cd examples/query-playground && yarn start",
"docs:build": "mkdir -p dist && cp docs/index.html dist/ && yarn build:playground",
"docs:serve": "d2-utils-docsite serve ./docs -o ./dist",
"lint": "d2-style check js && d2-style check text"
"lint": "d2-style check js && d2-style check text",
"postinstall": "patch-package"
},
"d2": {
"docsite": {
"name": "DHIS2 Application Runtime",
"description": "A singular runtime dependency for applications on the [DHIS2 platform](https://platform.dhis2.nu)"
}
},
"dependencies": {
"patch-package": "^8.0.0",
"postinstall-postinstall": "^2.1.0"
}
}
10 changes: 10 additions & 0 deletions patches/react-query+3.13.11.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
diff --git a/node_modules/react-query/types/react/QueryClientProvider.d.ts b/node_modules/react-query/types/react/QueryClientProvider.d.ts
index 65e1214..ea9fbf0 100644
--- a/node_modules/react-query/types/react/QueryClientProvider.d.ts
+++ b/node_modules/react-query/types/react/QueryClientProvider.d.ts
@@ -10,4 +10,4 @@ export interface QueryClientProviderProps {
client: QueryClient;
contextSharing?: boolean;
}
-export declare const QueryClientProvider: React.FC<QueryClientProviderProps>;
+export declare const QueryClientProvider: React.FC<React.PropsWithChildren<QueryClientProviderProps>>;
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
2 changes: 1 addition & 1 deletion services/alerts/src/useAlert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const useAlert = (
const alertRef = useRef(<Alert | null>null)

const show = useCallback(
(props?) => {
(props?: any) => {
const resolvedMessage = String(
typeof message === 'function' ? message(props) : message
)
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
2 changes: 1 addition & 1 deletion services/config/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type Version = {
tag?: string
}

export type DateInput = string | Date | number | null
export type DateInput = string | Date | number | null | undefined

interface SystemInfo {
version: string
Expand Down
Loading
Loading