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(react): Upgrade to React 18 #4992

Merged
merged 50 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
dee0adb
chore: upgrade to react 18
virtuoushub Mar 30, 2022
1fea52e
chore(@testing-library/react): switch to version 13
virtuoushub Jul 7, 2022
03bee6e
build(yarn): remove duplicates defined at top level
virtuoushub Jul 7, 2022
f7943ec
chore(react@18): remove `unstable_batchedUpdates`
virtuoushub Mar 30, 2022
f643edc
fix(typescript): cast to get typescript error to go away
virtuoushub Jun 15, 2022
c0b63dc
fix(typescript): needed to get typescript error to go away
virtuoushub Jun 15, 2022
b0cd7db
test(unit): skip failing test
virtuoushub Nov 2, 2022
e3f3357
chore(test@unit.snapshots): update snapshots
virtuoushub Nov 2, 2022
46c3d50
chore(deps): run dedupe
virtuoushub Nov 2, 2022
4fe7bd0
chore(fixtures): update
virtuoushub Oct 2, 2022
36fb1d9
chore(codemods): fix for TypeScript / Auth stuff?
virtuoushub Nov 2, 2022
083e3f6
Revert "chore(codemods): fix for TypeScript / Auth stuff?"
virtuoushub Nov 2, 2022
7204c96
test(unit): skip flakey windows test
virtuoushub Nov 2, 2022
32837b0
doc(📓): correct URL
virtuoushub Dec 22, 2022
34c5e48
Merge remote-tracking branch 'upstream/main' into chore/upgrade-to-re…
virtuoushub Jan 17, 2023
9ece86e
chore(deps): bump react type
virtuoushub Jan 17, 2023
9bd6ac2
chore(deps): remove stale dep
virtuoushub Jan 17, 2023
9d1e6c6
chore(deps): bump react
virtuoushub Jan 17, 2023
f08b794
chore(deps): alight react type versions
virtuoushub Jan 17, 2023
a4dc36f
chore(deps): 🤷‍♀️
virtuoushub Jan 17, 2023
e8bef71
chore(deps): bump react-dom types
virtuoushub Jan 17, 2023
2c3ad65
fix(typescript): for build failure
virtuoushub Jan 17, 2023
d1632e0
chore: bring back commented out tests
virtuoushub Jan 17, 2023
65ea887
chore: favor inline `children` prop definition
virtuoushub Jan 17, 2023
295fd75
chore(test@ci): fix for failing smoke test
virtuoushub Jan 17, 2023
6f5e4d3
chore(test@ci): fix for failing smoke test
virtuoushub Jan 17, 2023
eb2b72f
chore(test@ci): fix for failing smoke test
virtuoushub Jan 17, 2023
fd61c2a
Revert "chore(test@ci): fix for failing smoke test"
virtuoushub Jan 17, 2023
76dc333
chore: rebuild project fixture
virtuoushub Jan 17, 2023
24987c7
chore: try bumping the default jest timeout
virtuoushub Jan 17, 2023
e8740ab
chore: add to all slow tests
virtuoushub Jan 18, 2023
6e2f09c
Hardcode currentUser attributes
Tobbe Jan 18, 2023
f2ba874
router.test.tsx: Format source, and increase timeout
Tobbe Jan 18, 2023
f33567d
Merge branch 'main' into chore/upgrade-to-react-18
Tobbe Jan 18, 2023
f4b29f7
yarn.lock
Tobbe Jan 18, 2023
dba56cc
chore(deps): bump `@types/react`
virtuoushub Jan 19, 2023
e9bcf8e
Merge branch 'main' into chore/upgrade-to-react-18
virtuoushub Jan 19, 2023
883ab5d
Merge branch 'main' into chore/upgrade-to-react-18
virtuoushub Jan 19, 2023
b211f25
Merge branch 'main' into chore/upgrade-to-react-18
Tobbe Jan 20, 2023
a53b2ca
Merge branch 'main' into chore/upgrade-to-react-18
virtuoushub Jan 23, 2023
497faa0
Merge remote-tracking branch 'origin/chore/upgrade-to-react-18' into …
virtuoushub Jan 23, 2023
4431f81
Update packages/auth-providers/auth0/web/package.json
virtuoushub Jan 23, 2023
bea2239
chore: fix failed merge resolve
virtuoushub Jan 23, 2023
f862d12
chore: fix failed merge resolve
virtuoushub Jan 23, 2023
242926c
chore: remove resolutions
jtoar Jan 23, 2023
9007239
chore: remove typescript-transform-paths
jtoar Jan 23, 2023
0857588
Merge branch 'main' into chore/upgrade-to-react-18
jtoar Jan 23, 2023
2fe67d0
fix: proxies forgotPassword test
jtoar Jan 23, 2023
3e698d1
fix: revert docs react upgrade
jtoar Jan 23, 2023
3826c4f
fix: use toBeCalledWith instead of toBe on length
jtoar Jan 23, 2023
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 __fixtures__/test-project/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"@redwoodjs/web": "3.2.0",
"humanize-string": "2.1.0",
virtuoushub marked this conversation as resolved.
Show resolved Hide resolved
"prop-types": "15.8.1",
"react": "17.0.2",
"react-dom": "17.0.2"
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"autoprefixer": "^10.4.13",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,18 @@ const ProfilePage = () => {
</tr>
</thead>
<tbody>
{Object.keys(currentUser).map((key) => {
return (
<tr key={key}>
<td>{key.toUpperCase()}</td>
<td>{currentUser[key]}</td>
</tr>
)
})}
<tr>
<td>ID</td>
<td>{currentUser.id}</td>
</tr>
<tr>
<td>ROLES</td>
<td>{currentUser.roles}</td>
</tr>
<tr>
<td>EMAIL</td>
<td>{currentUser.email}</td>
</tr>

<tr key="isAuthenticated">
<td>isAuthenticated</td>
Expand Down
38 changes: 38 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,47 @@ module.exports = {
},
],
'@babel/preset-react',
/**
* TODO(pc): w/ '@babel/plugin-transform-typescript' in plugins now, is '@babel/typescript' preset still needed?
*
* - Plugins run before Presets.
* - Plugin ordering is first to last.
* - Preset ordering is reversed (last to first).
*
* https://babeljs.io/docs/en/plugins/#plugin-ordering
*/
'@babel/typescript',
],
plugins: [
/**
* NOTE
* Needed for react@18
*
* ```
* ✖ @redwoodjs/router:build
* SyntaxError: /code/redwood/packages/router/src/location.tsx: TypeScript 'declare' fields must first be transformed by @babel/plugin-transform-typescript.
* If you have already enabled that plugin (or '@babel/preset-typescript'), make sure that it runs before any plugin related to additional class features:
* - @babel/plugin-proposal-class-properties
* - @babel/plugin-proposal-private-methods
* - @babel/plugin-proposal-decorators
* 25 | // When prerendering, there might be more than one level of location
* 26 | // providers. Use the values from the one above.
* > 27 | declare context: React.ContextType<typeof LocationContext>
* | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* 28 | HISTORY_LISTENER_ID: string | undefined = undefined
* 29 |
* 30 | state = {
* ```
*/
[
'@babel/plugin-transform-typescript',
{
allowDeclareFields: true,
/** needed in order build `packages/web/dist/entry/index.js` */
isTSX: true,
allExtensions: true,
},
],
jtoar marked this conversation as resolved.
Show resolved Hide resolved
/**
* NOTE
* Experimental decorators are used in `@redwoodjs/structure`.
Expand Down
8 changes: 5 additions & 3 deletions docs/docs/custom-web-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ yarn rw setup custom-web-index
This generates a file named `index.js` in `web/src` that looks like this:

```jsx title="web/src/index.js"
import ReactDOM from 'react-dom'
import { hydrateRoot, createRoot } from 'react-dom/client'

import App from './App'
/**
Expand All @@ -31,9 +31,11 @@ import App from './App'
const rootElement = document.getElementById('redwood-app')

if (rootElement.hasChildNodes()) {
ReactDOM.hydrate(<App />, rootElement)
hydrateRoot(redwoodAppElement, <App />)
} else {
ReactDOM.render(<App />, rootElement)
const root = createRoot(redwoodAppElement)
root.render(<App />)
}
```

This's actually the same file Redwood uses [internally](https://github.com/redwoodjs/redwood/blob/main/packages/web/src/entry/index.js).
Expand Down
9 changes: 1 addition & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@
"test-ci": "lerna run test --concurrency 2 -- --colors --maxWorkers"
},
"resolutions": {
"@types/react": "17.0.53",
"microtime": "3.1.1",
"prop-types": "15.8.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"typescript": "4.7.4",
"vscode-languageserver": "6.1.1",
"vscode-languageserver-protocol": "3.15.3",
"vscode-languageserver-textdocument": "1.0.8",
Expand Down Expand Up @@ -61,8 +55,7 @@
"@playwright/test": "1.29.2",
"@replayio/playwright": "0.3.15",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "12.1.5",
"@testing-library/react-hooks": "8.0.1",
"@testing-library/react": "13.4.0",
"@testing-library/user-event": "14.4.3",
"@tsd/typescript": "4.9.4",
"@types/babel__generator": "7.6.4",
Expand Down
5 changes: 2 additions & 3 deletions packages/auth-providers/auth0/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@
"@auth0/auth0-spa-js": "1.22.6",
"@babel/cli": "7.20.7",
"@babel/core": "7.20.12",
"@testing-library/react-hooks": "8.0.1",
"@types/react": "17.0.53",
"@types/react": "18.0.27",
"jest": "29.3.1",
"react": "17.0.2",
"react": "18.2.0",
"typescript": "4.7.4"
virtuoushub marked this conversation as resolved.
Show resolved Hide resolved
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
GetTokenSilentlyVerboseResponse,
User,
} from '@auth0/auth0-spa-js'
import { renderHook, act } from '@testing-library/react-hooks'
import { renderHook, act } from '@testing-library/react'

import { CurrentUser } from '@redwoodjs/auth'

Expand Down
5 changes: 2 additions & 3 deletions packages/auth-providers/azureActiveDirectory/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@
"@azure/msal-browser": "2.32.2",
"@babel/cli": "7.20.7",
"@babel/core": "7.20.12",
"@testing-library/react-hooks": "8.0.1",
jtoar marked this conversation as resolved.
Show resolved Hide resolved
"@types/netlify-identity-widget": "1.9.3",
"@types/react": "17.0.53",
"@types/react": "18.0.27",
"jest": "29.3.1",
"react": "17.0.2",
"react": "18.2.0",
"typescript": "4.7.4"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
PublicClientApplication as AzureActiveDirectoryClient,
RedirectRequest,
} from '@azure/msal-browser'
import { renderHook, act } from '@testing-library/react-hooks'
import { renderHook, act } from '@testing-library/react'

import { CurrentUser } from '@redwoodjs/auth'

Expand Down
5 changes: 2 additions & 3 deletions packages/auth-providers/clerk/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@
"@babel/core": "7.20.12",
"@clerk/clerk-react": "3.5.1",
"@clerk/types": "2.21.0",
"@testing-library/react-hooks": "8.0.1",
"@types/react": "17.0.53",
"@types/react": "18.0.27",
"jest": "29.3.1",
"react": "17.0.2",
"react": "18.2.0",
"typescript": "4.7.4"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
EmailAddressResource,
ActiveSessionResource,
} from '@clerk/types'
import { renderHook, act } from '@testing-library/react-hooks'
import { renderHook, act } from '@testing-library/react'

import { CurrentUser } from '@redwoodjs/auth'

Expand Down
5 changes: 2 additions & 3 deletions packages/auth-providers/dbAuth/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@
"@babel/cli": "7.20.7",
"@babel/core": "7.20.12",
"@simplewebauthn/typescript-types": "6.2.1",
"@testing-library/react-hooks": "8.0.1",
"@types/react": "17.0.53",
"@types/react": "18.0.27",
"jest": "29.3.1",
"react": "17.0.2",
"react": "18.2.0",
"typescript": "4.7.4"
},
"gitHead": "3905ed045508b861b495f8d5630d76c7a157d8f1"
Expand Down
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 { CurrentUser } from '@redwoodjs/auth'

Expand Down
5 changes: 2 additions & 3 deletions packages/auth-providers/firebase/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@
"devDependencies": {
"@babel/cli": "7.20.7",
"@babel/core": "7.20.12",
"@testing-library/react-hooks": "8.0.1",
"@types/react": "17.0.53",
"@types/react": "18.0.27",
"firebase": "9.16.0",
"jest": "29.3.1",
"react": "17.0.2",
"react": "18.2.0",
"typescript": "4.7.4"
},
"peerDependencies": {
Expand Down
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 type FirebaseAuthNamespace from 'firebase/auth'
import { User, OperationType, OAuthProvider, Auth } from 'firebase/auth'

Expand Down
5 changes: 2 additions & 3 deletions packages/auth-providers/netlify/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@
"devDependencies": {
"@babel/cli": "7.20.7",
"@babel/core": "7.20.12",
"@testing-library/react-hooks": "8.0.1",
"@types/netlify-identity-widget": "1.9.3",
"@types/react": "17.0.53",
"@types/react": "18.0.27",
"jest": "29.3.1",
"react": "17.0.2",
"react": "18.2.0",
"typescript": "4.7.4"
},
"peerDependencies": {
Expand Down
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 * as NetlifyIdentityNS from 'netlify-identity-widget'

import { CurrentUser } from '@redwoodjs/auth'
Expand Down
5 changes: 2 additions & 3 deletions packages/auth-providers/supabase/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
"@babel/cli": "7.20.7",
"@babel/core": "7.20.12",
"@supabase/supabase-js": "1.35.7",
"@testing-library/react-hooks": "8.0.1",
"@types/react": "17.0.53",
"@types/react": "18.0.27",
"jest": "29.3.1",
"react": "17.0.2",
"react": "18.2.0",
"typescript": "4.7.4"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { SupabaseClient, User } from '@supabase/supabase-js'
import { renderHook, act } from '@testing-library/react-hooks'
import { renderHook, act } from '@testing-library/react'

import { CurrentUser } from '@redwoodjs/auth'

Expand Down
5 changes: 2 additions & 3 deletions packages/auth-providers/supertokens/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
"devDependencies": {
"@babel/cli": "7.20.7",
"@babel/core": "7.20.12",
"@testing-library/react-hooks": "8.0.1",
"@types/react": "17.0.53",
"@types/react": "18.0.27",
"jest": "29.3.1",
"react": "17.0.2",
"react": "18.2.0",
"typescript": "4.7.4"
},
"peerDependencies": {
Expand Down
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 { CurrentUser } from '@redwoodjs/auth'

Expand Down
5 changes: 2 additions & 3 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"core-js": "3.27.2",
"react": "17.0.2"
"react": "18.2.0"
},
"devDependencies": {
"@babel/cli": "7.20.7",
"@babel/core": "7.20.12",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "12.1.5",
"@testing-library/react-hooks": "8.0.1",
"@testing-library/react": "13.4.0",
"jest": "29.3.1",
"msw": "0.49.3",
"typescript": "4.7.4"
Expand Down
6 changes: 2 additions & 4 deletions packages/auth/src/__tests__/AuthProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
waitFor,
configure,
} from '@testing-library/react'
import { renderHook, act } from '@testing-library/react-hooks'
import { renderHook, act } from '@testing-library/react'
import '@testing-library/jest-dom/extend-expect'
import { graphql } from 'msw'
import { setupServer } from 'msw/node'
Expand Down Expand Up @@ -711,9 +711,7 @@ describe('Custom auth provider', () => {
</AuthProvider>
)

await waitFor(() => mockedForgotPassword.mock.calls.length === 1)

expect.assertions(1)
await waitFor(() => expect(mockedForgotPassword).toBeCalledWith('username'))
})

test('proxies resetPassword() calls to client', async () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/create-redwood-app/template/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@redwoodjs/router": "3.2.0",
"@redwoodjs/web": "3.2.0",
"prop-types": "15.8.1",
"react": "17.0.2",
"react-dom": "17.0.2"
"react": "18.2.0",
"react-dom": "18.2.0"
Comment on lines +20 to +21
Copy link
Contributor

Choose a reason for hiding this comment

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

Kind of feels like we shouldn't be pinning these in the CRWA template; let me see what that involves.

}
}
12 changes: 6 additions & 6 deletions packages/forms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,22 @@
"@babel/core": "7.20.12",
"@testing-library/dom": "8.20.0",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "12.1.5",
"@testing-library/react": "13.4.0",
"@testing-library/user-event": "14.4.3",
"@types/pascalcase": "1.0.1",
"@types/react": "17.0.53",
"@types/react-dom": "17.0.18",
"@types/react": "18.0.27",
"@types/react-dom": "18.0.10",
"@types/testing-library__jest-dom": "5.14.5",
"graphql": "16.6.0",
"jest": "29.3.1",
"nodemon": "2.0.20",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "4.7.4"
},
"peerDependencies": {
"graphql": "16.6.0",
"react": "17.0.2"
"react": "18.2.0"
},
"gitHead": "3905ed045508b861b495f8d5630d76c7a157d8f1"
}
4 changes: 2 additions & 2 deletions packages/prerender/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
"typescript": "4.7.4"
},
"peerDependencies": {
"react": "17.0.2",
"react-dom": "17.0.2"
"react": "18.2.0",
"react-dom": "18.2.0"
},
"externals": {
"react": "react",
Expand Down
Loading