Skip to content

Commit

Permalink
Revert "feat(react): Upgrade to React 18 (#4992)"
Browse files Browse the repository at this point in the history
This reverts commit 51f7f25.
  • Loading branch information
jtoar committed Jan 30, 2023
1 parent a89f8d0 commit 5a2c717
Show file tree
Hide file tree
Showing 39 changed files with 511 additions and 541 deletions.
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": "4.0.0",
"humanize-string": "2.1.0",
"prop-types": "15.8.1",
"react": "18.2.0",
"react-dom": "18.2.0"
"react": "17.0.2",
"react-dom": "17.0.2"
},
"devDependencies": {
"autoprefixer": "^10.4.13",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,14 @@ const ProfilePage = () => {
</tr>
</thead>
<tbody>
<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>
{Object.keys(currentUser).map((key) => {
return (
<tr key={key}>
<td>{key.toUpperCase()}</td>
<td>{currentUser[key]}</td>
</tr>
)
})}

<tr key="isAuthenticated">
<td>isAuthenticated</td>
Expand Down
38 changes: 0 additions & 38 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,47 +38,9 @@ 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,
},
],
/**
* NOTE
* Experimental decorators are used in `@redwoodjs/structure`.
Expand Down
8 changes: 3 additions & 5 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 { hydrateRoot, createRoot } from 'react-dom/client'
import ReactDOM from 'react-dom'

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

if (rootElement.hasChildNodes()) {
hydrateRoot(redwoodAppElement, <App />)
ReactDOM.hydrate(<App />, rootElement)
} else {
const root = createRoot(redwoodAppElement)
root.render(<App />)
}
ReactDOM.render(<App />, rootElement)
```
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: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
"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 @@ -55,7 +61,8 @@
"@playwright/test": "1.30.0",
"@replayio/playwright": "0.3.16",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "13.4.0",
"@testing-library/react": "12.1.5",
"@testing-library/react-hooks": "8.0.1",
"@testing-library/user-event": "14.4.3",
"@tsd/typescript": "4.9.4",
"@types/babel__generator": "7.6.4",
Expand Down
5 changes: 3 additions & 2 deletions packages/auth-providers/auth0/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@
"@auth0/auth0-spa-js": "1.22.6",
"@babel/cli": "7.20.7",
"@babel/core": "7.20.12",
"@types/react": "18.0.27",
"@testing-library/react-hooks": "8.0.1",
"@types/react": "17.0.53",
"jest": "29.4.1",
"react": "18.2.0",
"react": "17.0.2",
"typescript": "4.9.4"
},
"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'
import { renderHook, act } from '@testing-library/react-hooks'

import { CurrentUser } from '@redwoodjs/auth'

Expand Down
5 changes: 3 additions & 2 deletions packages/auth-providers/azureActiveDirectory/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@
"@azure/msal-browser": "2.32.2",
"@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": "18.0.27",
"@types/react": "17.0.53",
"jest": "29.4.1",
"react": "18.2.0",
"react": "17.0.2",
"typescript": "4.9.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'
import { renderHook, act } from '@testing-library/react-hooks'

import { CurrentUser } from '@redwoodjs/auth'

Expand Down
5 changes: 3 additions & 2 deletions packages/auth-providers/clerk/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
"@babel/core": "7.20.12",
"@clerk/clerk-react": "4.9.0",
"@clerk/types": "3.25.0",
"@types/react": "18.0.27",
"@testing-library/react-hooks": "8.0.1",
"@types/react": "17.0.53",
"jest": "29.4.1",
"react": "18.2.0",
"react": "17.0.2",
"typescript": "4.9.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'
import { renderHook, act } from '@testing-library/react-hooks'

import { CurrentUser } from '@redwoodjs/auth'

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

import { CurrentUser } from '@redwoodjs/auth'

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

Expand Down
5 changes: 3 additions & 2 deletions packages/auth-providers/netlify/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
"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": "18.0.27",
"@types/react": "17.0.53",
"jest": "29.4.1",
"react": "18.2.0",
"react": "17.0.2",
"typescript": "4.9.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'
import { renderHook, act } from '@testing-library/react-hooks'
import * as NetlifyIdentityNS from 'netlify-identity-widget'

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

import { CurrentUser } from '@redwoodjs/auth'

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

import { CurrentUser } from '@redwoodjs/auth'

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

await waitFor(() => expect(mockedForgotPassword).toBeCalledWith('username'))
await waitFor(() => mockedForgotPassword.mock.calls.length === 1)

expect.assertions(1)
})

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": "4.0.0",
"@redwoodjs/web": "4.0.0",
"prop-types": "15.8.1",
"react": "18.2.0",
"react-dom": "18.2.0"
"react": "17.0.2",
"react-dom": "17.0.2"
}
}
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": "13.4.0",
"@testing-library/react": "12.1.5",
"@testing-library/user-event": "14.4.3",
"@types/pascalcase": "1.0.1",
"@types/react": "18.0.27",
"@types/react-dom": "18.0.10",
"@types/react": "17.0.53",
"@types/react-dom": "17.0.18",
"@types/testing-library__jest-dom": "5.14.5",
"graphql": "16.6.0",
"jest": "29.4.1",
"nodemon": "2.0.20",
"react": "18.2.0",
"react-dom": "18.2.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"typescript": "4.9.4"
},
"peerDependencies": {
"graphql": "16.6.0",
"react": "18.2.0"
"react": "17.0.2"
},
"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.9.4"
},
"peerDependencies": {
"react": "18.2.0",
"react-dom": "18.2.0"
"react": "17.0.2",
"react-dom": "17.0.2"
},
"externals": {
"react": "react",
Expand Down
Loading

0 comments on commit 5a2c717

Please sign in to comment.