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

Conversation

virtuoushub
Copy link
Collaborator

@virtuoushub virtuoushub commented Apr 2, 2022


⚠️⚠️⚠️ 🚧 🏗️ 🚧 ⚠️⚠️⚠️

For RW application developers wanting to try out React 18

you don't need to wait for this PR to be merged in or released; to try out React 18 in your Redwood projects ✨right now✨:

  1. Update web/package.json to bump React's version to 18: e.g. fix(deps): update react monorepo to v18 (major) example-storybook#12
  2. Add custom web index web/src/index.js: e.g. https://github.com/redwoodjs/example-storybook/pull/144/files
    1. see also: https://redwoodjs.com/docs/cli-commands#setup-custom-web-index
import { hydrateRoot, createRoot } from 'react-dom/client'

import App from './App'
/**
 * When `#redwood-app` isn't empty then it's very likely that you're using
 * prerendering. So React attaches event listeners to the existing markup
 * rather than replacing it.
 * https://reactjs.org/docs/react-dom.html#hydrate
 */
const redwoodAppElement = document.getElementById('redwood-app')

if (redwoodAppElement.children?.length > 0) {
  hydrateRoot(redwoodAppElement, <App />)
} else {
  const root = createRoot(redwoodAppElement)
  root.render(<App />)
}

note: the example-storybook project is in JavaScript, so if your project uses TypeScript then you'll also want to bump the relevant React @types/* dependencies

also note: React 18 support in Redwood is currently experimental, so please try at your own risk


What was done in this PR

- ): RenderHookResult<Props, Result> => {
+ ): RenderHookResult<Result, Props> => {

PR Notes

Redwood deps we need to have React 18 support before upgrading
(links to open Issue(s) if applicable)

  • 🤷🏻

Redwood deps that require React 18

Redwood deps that are incompatible with React 18

  • Docusarus note: this is only used in the docs and not the core code

Outstanding Goals (can be separate from this PR if it makes sense)

  • Want to explore how best to accommodate pre react@18 usage, what a frictionless upgrade might be, and what a codemod(s?) might look like.
    • @jtoar to provide list of commands to smoke test, findings from that can inform what a "frictionless" upgrade might look like
  • Explore how Cells might be updated / redesigned with Suspense out of scope for this PR

See also:

@netlify
Copy link

netlify bot commented Apr 2, 2022

Deploy Preview for redwoodjs-docs ready!

Name Link
🔨 Latest commit 665037c
🔍 Latest deploy log https://app.netlify.com/sites/redwoodjs-docs/deploys/62def502c7027a0008f351b1
😎 Deploy Preview https://deploy-preview-4992--redwoodjs-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@thedavidprice
Copy link
Contributor

@virtuoushub one important, helpful thing you could do in the OP is list the Redwood deps we need to have React 18 support before upgrading with link to open Issue if applicable. fwiw

@virtuoushub virtuoushub self-assigned this Apr 25, 2022
@virtuoushub virtuoushub closed this May 5, 2022
@virtuoushub virtuoushub changed the title Explore upgrade to react 18 [draft] chore(react): Explore upgrade to react 18 Jun 23, 2022
@virtuoushub
Copy link
Collaborator Author

reopening, in case someone is interested in helping.

@virtuoushub virtuoushub reopened this Jun 23, 2022
@jtoar jtoar linked an issue Jul 8, 2022 that may be closed by this pull request
1 task
@virtuoushub virtuoushub force-pushed the chore/upgrade-to-react-18 branch 2 times, most recently from b0b0b72 to 9e0f18b Compare July 11, 2022 15:22
@virtuoushub virtuoushub force-pushed the chore/upgrade-to-react-18 branch 2 times, most recently from f57d861 to 49746aa Compare July 15, 2022 00:43
@nx-cloud
Copy link

nx-cloud bot commented Jul 25, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 665037c. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


🟥 Failed Commands
cli run test --concurrency 2 -- --colors --maxWorkers 2
cli run test --concurrency 2 -- --colors --maxWorkers 2
✅ Successfully ran 9 targets

Sent with 💌 from NxCloud.

babel.config.js Outdated Show resolved Hide resolved
@standuprey
Copy link
Contributor

Wouldn't this be an opportunity to upgrade to chakra 2? https://github.com/redwoodjs/redwood/tree/main/packages/cli/src/commands/setup/ui/libraries/chakra-ui.js#L31

@virtuoushub
Copy link
Collaborator Author

virtuoushub commented Sep 2, 2022

Wouldn't this be an opportunity to upgrade to chakra 2? https://github.com/redwoodjs/redwood/tree/main/packages/cli/src/commands/setup/ui/libraries/chakra-ui.js#L31

Yes, although that upgrade will most likely happen in a different PR. Will add a note that it is a known dependency and that people interested in using it are waiting on this.

# Conflicts:
#	__fixtures__/test-project/api/db/migrations/20220101120000_create_post_user/migration.sql
#	__fixtures__/test-project/api/db/migrations/20220102120000_create_contact/migration.sql
#	__fixtures__/test-project/api/db/migrations/20230114191659_create_post_user/migration.sql
#	__fixtures__/test-project/api/db/migrations/20230114191819_create_contact/migration.sql
#	__fixtures__/test-project/api/db/migrations/20230118153725_create_post_user/migration.sql
#	__fixtures__/test-project/api/db/migrations/20230118153843_create_contact/migration.sql
#	__fixtures__/test-project/api/package.json
#	__fixtures__/test-project/api/src/services/posts/posts.scenarios.ts
#	__fixtures__/test-project/api/src/services/users/users.scenarios.ts
#	__fixtures__/test-project/web/package.json
#	package.json
#	packages/auth-providers/auth0/web/package.json
#	packages/auth-providers/azureActiveDirectory/web/package.json
#	packages/auth-providers/clerk/web/package.json
#	packages/auth-providers/dbAuth/web/package.json
#	packages/auth-providers/firebase/web/package.json
#	packages/auth-providers/netlify/web/package.json
#	packages/auth-providers/supabase/web/package.json
#	packages/auth-providers/supertokens/web/package.json
#	packages/auth/package.json
#	packages/forms/package.json
#	packages/router/package.json
#	packages/testing/package.json
#	packages/web/package.json
#	yarn.lock
docs/package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
babel.config.js Show resolved Hide resolved
Comment on lines +20 to +21
"react": "18.2.0",
"react-dom": "18.2.0"
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.

package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@jtoar jtoar merged commit 51f7f25 into redwoodjs:main Jan 23, 2023
@redwoodjs-bot redwoodjs-bot bot added this to the next-release milestone Jan 23, 2023
@jtoar jtoar removed this from the next-release milestone Jan 23, 2023
@virtuoushub virtuoushub deleted the chore/upgrade-to-react-18 branch January 23, 2023 22:22
@jtoar jtoar added this to the v5.0.0 milestone Jan 26, 2023
jtoar added a commit that referenced this pull request Jan 30, 2023
virtuoushub added a commit to virtuoushub/redwood that referenced this pull request Feb 16, 2023
> Version 2 of Chakra UI is only compatible with React 18. If you are still needing to use React 17 or earlier, please use version 1 of Chakra UI.

see also:

- https://chakra-ui.com/getting-started
- redwoodjs#4992 (comment)
- redwoodjs#5614
virtuoushub added a commit to virtuoushub/redwood that referenced this pull request Feb 17, 2023
> Version 2 of Chakra UI is only compatible with React 18. If you are still needing to use React 17 or earlier, please use version 1 of Chakra UI.

see also:

- https://chakra-ui.com/getting-started
- redwoodjs#4992 (comment)
- redwoodjs#5614
virtuoushub added a commit to virtuoushub/redwood that referenced this pull request Feb 21, 2023
> Version 2 of Chakra UI is only compatible with React 18. If you are still needing to use React 17 or earlier, please use version 1 of Chakra UI.

see also:

- https://chakra-ui.com/getting-started
- redwoodjs#4992 (comment)
- redwoodjs#5614
jtoar added a commit that referenced this pull request Feb 21, 2023
* chore(deps): bump Chakra UI to V2

> Version 2 of Chakra UI is only compatible with React 18. If you are still needing to use React 17 or earlier, please use version 1 of Chakra UI.

see also:

- https://chakra-ui.com/getting-started
- #4992 (comment)
- #5614

* Update packages/cli/src/commands/setup/ui/libraries/chakra-ui.js

Co-authored-by: Dominic Saadi <dominiceliassaadi@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

[RFC]: Upgrading to React 18 for Redwood
8 participants