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

chore(deps): bump setup of Chakra UI to V2 #7649

Merged

Conversation

virtuoushub
Copy link
Collaborator

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:

@virtuoushub virtuoushub requested a review from jtoar February 16, 2023 01:39
@virtuoushub virtuoushub force-pushed the chore/react-18/upgrade-chakra-ui-to-v2 branch from 9bd78ce to 302159f Compare February 17, 2023 12:38
@jtoar jtoar added release:breaking This PR is a breaking change fixture-ok Override the test project fixture check labels Feb 20, 2023
Copy link
Contributor

@jtoar jtoar left a comment

Choose a reason for hiding this comment

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

Looks good @virtuoushub, and looks like this really is all the changes we'll have to make on the framework's side. There's a few more breaking changes, but those are only relevant if you're using specific Chakra components. We'll just have to refer users to Chakra's migration guide in the release notes.

packages/cli/src/commands/setup/ui/libraries/chakra-ui.js Outdated Show resolved Hide resolved
virtuoushub and others added 2 commits February 21, 2023 09:23
> 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 virtuoushub force-pushed the chore/react-18/upgrade-chakra-ui-to-v2 branch from 6e55215 to b28c0d1 Compare February 21, 2023 14:24
@jtoar jtoar merged commit f044dcd into redwoodjs:main Feb 21, 2023
@redwoodjs-bot redwoodjs-bot bot added this to the next-release milestone Feb 21, 2023
@virtuoushub virtuoushub deleted the chore/react-18/upgrade-chakra-ui-to-v2 branch February 21, 2023 18:59
@jtoar jtoar modified the milestones: next-release, v4.2.0, v5.0.0 Feb 22, 2023
@adriatic
Copy link
Contributor

adriatic commented Feb 26, 2023

The following paragraphs are written for a potential benefit to @virtuoushub and @jtoar - no need to comment (or even read) any of that:


I will test the Redwood 4.2 (do I need to get some newer version ?) with Chakra latest and report back here.

The recommendation "If you are still needing to use React 17 or earlier, please use version 1 of Chakra UI." may not be very helpful as I spent some time to try that path and the documentation for Chakra v1 and Redwood (https://v1.chakra-ui.com/guides/first-steps) is broken. I discussed this with a member of Chakra team (Lazar Nikolov) and he wasn't able to help. (it seems that this documentation was created by someone from Redwood (my guess))

Running the minimal RedwoodJS app results with the message:

Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot

This is not surprising, since my RW app defined the dependencies as


 "dependencies": {
    "@redwoodjs/forms": "4.2.0",
    "@redwoodjs/router": "4.2.0",
    "@redwoodjs/web": "4.2.0",
    "prop-types": "15.8.1",
    "react": "18.2.0",
    "react-dom": "18.2.0"
  }

My interpretation is that @jtoar's comment suggests that the current RW release does not address the React's 18 issue Use createRoot instead, yet.

Also notice to @dennemark with respect to his comment at discord

I am using chakra v2 and redwood with react 18 for a while now. No issues so far.

I believe that you did not look at the devtools console, right?

@virtuoushub
Copy link
Collaborator Author

Hi @adriatic, thanks for your comment. Is there something specific with this PR which is causing issues with your project?

Also friendly reminder React 18 support in Redwood is currently experimental, so please use it at your own risk.


I will test the Redwood 4.2 (do I need to get some newer version ?) with Chakra latest and report back here.

Redwood 5+ ( canary as of the time of this writing) is a valid test.


may not be very helpful as I spent some time to try that path and the documentation for Chakra v1 and Redwood (https://v1.chakra-ui.com/guides/first-steps) is broken

Is this documented somewhere? Was not aware of a broken Chakra integration.

Also what is meant by broken? is it that

Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot

Shows up in the console? Because depending on the version combinations used, that is the expected behavior.


My interpretation is that #7649 (review) suggests that the current RW release does not address the React's 18 issue Use createRoot instead, yet.

While the current 4.x RW releases do not have the createRoot API update, canary does. The workaround to get this to work in versions less than 5 (canary) is documented over at #4992

Looking at your https://github.com/adriatic/rw-chakra I did not notice any web/src/index.js which is why you see that Warning: ReactDOM.render is no longer supported... warning.

Please either upgrade redwood to canary or add a custom web index (web/src/index.js) as documented on #4992 to try and get that warning to go away.

@adriatic
Copy link
Contributor

adriatic commented Feb 27, 2023

Hi @adriatic, thanks for your comment. Is there something specific with this PR which is causing issues with your project?

Hello, @virtuoushub
Probably the biggest issue is described in my just published post Typescript 4.2 import paths breaking change, which requires the change in RedwoodJS generated file tsconfig

Also friendly reminder React 18 support in Redwood is currently experimental, so please use it at your own risk.

Thanks, I understand your warning

I will test the Redwood 4.2 (do I need to get some newer version ?) with Chakra latest and report back here.

Redwood 5+ ( canary as of the time of this writing) is a valid test.

Ack

... the documentation for Chakra v1 and Redwood (https://v1.chakra-ui.com/guides/first-steps) is broken

Is this documented somewhere? Was not aware of a broken Chakra integration.

Also what is meant by broken?

Look at the site Chakra UI v 1.8.8 RedwoodJS integration guide and realize that the very first command to create Redwood setup is

yarn redwood setup ui chakra-ui

results with adding the Chakra UI v 2.x libraries. I discussed this with Chakra team member Lazar Nikolov

image

Neither of us knew who authored that guide.

Please either upgrade redwood to canary or add a custom web index (web/src/index.js) as documented on #4992 to try and get that warning to go away.

I decided to add custom web index (I am not sure about the need to do that, as not knowing about this "trick", I set the home page to at / (see this line and observe that the HomePage is "completely Chakra")

@adriatic
Copy link
Contributor

adriatic commented Feb 27, 2023

Added later:

  1. I modified the web/package.json to be
{
  "name": "web",
  "version": "0.0.0",
  "private": true,
  "browserslist": {
    "development": [
      "last 1 version"
    ],
    "production": [
      "defaults",
      "not IE 11",
      "not IE_Mob 11"
    ]
  },
  "dependencies": {
    "@redwoodjs/forms": "4.2.0",
    "@redwoodjs/router": "4.2.0",
    "@redwoodjs/web": "4.2.0",
    "prop-types": "15.8.1",
    "react": "17.0.2",
    "react-dom": "17.0.2"
  }
}

dac09 added a commit to dac09/redwood that referenced this pull request Feb 28, 2023
* 'main' of github.com:redwoodjs/redwood: (21 commits)
  chore(deps): update dependency @types/uuid to v9.0.1 (redwoodjs#7680)
  chore(deps): update dependency @replayio/playwright to v0.3.23 (redwoodjs#7677)
  chore(deps): update dependency @npmcli/arborist to v6.2.3 (redwoodjs#7675)
  chore(deps): update dependency @envelop/types to v3.0.2 (redwoodjs#7674)
  chore: add codemod for clerk fix in v4.2.0 (redwoodjs#7676)
  chore(deps): update dependency @clerk/types to v3.28.1 (redwoodjs#7652)
  chore(deps): update dependency @envelop/testing to v5.0.6 (redwoodjs#7673)
  Update directives.md (redwoodjs#7670)
  fix(deps): update dependency vscode-languageserver-types to v3.17.3 (redwoodjs#7636)
  Fix `yarn rw exec` to set nonzero exit code on error (redwoodjs#7660)
  fix(deps): update dependency core-js to v3.28.0 (redwoodjs#7666)
  fix(deps): update dependency @clerk/clerk-sdk-node to v4.7.4 (redwoodjs#7663)
  fix(deps): update dependency vite to v4.1.3 (redwoodjs#7664)
  fix(deps): update dependency @fastify/url-data to v5.3.1 (redwoodjs#7665)
  fix(deps): update dependency yargs to v17.7.1 (redwoodjs#7667)
  fix(clerk): Remove privateMetadata property from getCurrentUser (redwoodjs#7668)
  chore(deps): update dependency esbuild to v0.17.10 (redwoodjs#7662)
  chore(deps): bump setup of Chakra UI to V2 (redwoodjs#7649)
  Forms: Export EmptyAsValue (redwoodjs#7656)
  Update useRequireAuth docs to v4 auth (redwoodjs#7646)
  ...
@virtuoushub
Copy link
Collaborator Author

virtuoushub commented Mar 1, 2023

Hi again @adriatic, fwiw due to formatting I had a really difficult time following your response thread.

That being said to address:

Look at the site Chakra UI v 1.8.8 RedwoodJS integration guide and realize that the very first command to create Redwood setup is

yarn redwood setup ui chakra-ui
results with adding the Chakra UI v 2.x libraries. ...

I am unable to reproduce this behavior. Do you have a reproduction repo? I am unable to help without one.

For reference #5614 is used in Redwood v4.x and below (for the most part) and is there for the explicit purpose to pin Chakra UI to v1.

Here is what I see when running that command:

➜  yarn redwood setup ui chakra-ui

✔ Installing packages...
  ✔ Install @chakra-ui/react@^1, @emotion/react@^11, @emotion/styled@^11, framer-motion@^6
...

resulting web/package.json

{
...
  "dependencies": {
    "@chakra-ui/react": "^1",
    "@emotion/react": "^11",
    "@emotion/styled": "^11",
    "@redwoodjs/forms": "4.2.0",
    "@redwoodjs/router": "4.2.0",
    "@redwoodjs/web": "4.2.0",
    "framer-motion": "^6",
    "prop-types": "15.8.1",
...
  },
...
}

In case it helps clarify things, the PR we are currently commenting on bumps Chakra UI to V2 because we will be bumping to React 18 in Redwood v5 (#4992).

Currently there is no way to specify which version of a library to install via yarn rw setup ui <library>. If you want you can read up on this command here: https://redwoodjs.com/docs/cli-commands#setup-ui

If there was something missing in that document that you think others can benefit from, I encourage you to document it (can be done here: https://github.com/redwoodjs/redwood/blob/main/docs/docs/cli-commands.md#setup-ui).

If you want to explicitly set a version, please use yarn add similar to what is seen over at the manual section of the docs you referenced ( https://v1.chakra-ui.com/guides/getting-started/redwoodjs-guide#manual )

For example I modified their example slightly so that we pin chakra to v1. fwiw this is what #5614 does:

yarn add @chakra-ui/react^1 @emotion/react@^11 @emotion/styled@^11 framer-motion@^6


Also while I get your comments are Chakra related, I think we are getting into unrelated territory to this PR.

Unless it is related to this PR, if you think something is broken; please open a separate issue and add additional references where necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixture-ok Override the test project fixture check release:breaking This PR is a breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants