Ionic-framework: feat: Please update react dependencies version

Created on 8 Dec 2020  路  2Comments  路  Source: ionic-team/ionic-framework

Feature Request

Ionic version: 5.5.1
Usage: React

Describe the Feature Request
Could you update the dependencies of Ionic React? A lot of bugs happen when I try to integrate with my app.

Describe Preferred Solution
I don't know where the problem is coming from. But when I create a regular react app, those libraries work. I really think the problem is coming from dependencies but I'm not really sure.

Related Code
For those who want to test, the package is use_referred_state

The code to integrate it:

import React from "react"
const App: React.FC = () => {
    const [i, iRef, setI] = useReferredState<number>(0)

    useRef(() => {
        setI(iRef.current + 1)
   })
   return (
     <span>
        React updated State: {i} times
     </span>
  )
}

The Error
Capture d鈥櫭ヽran 2020-12-08 201730

AS I SAID THIS WORKS WHEN USING npx create-react-app COMMAND

triage

Most helpful comment

Thanks for the issue. The problem here is that your application likely has React 16 installed; however, use_referred_state requires React 17. This resulted in both React 16 and React 17 being installed (See Error 3 in the screenshot).

This is not really an Ionic Framework bug, but more of a dependency mismatch in your application. This does not happen in a CRA app since the latest CRA apps likely ship with React 17. That being said, I have relaxed the peer dependency requirement for Ionic React in https://github.com/ionic-team/ionic-framework/pull/22645 to accommodate some changes to npm 7. This relaxed requirement should be available in an upcoming release of Ionic Framework.

For now, I recommend installing React 17 manually:

npm install react@^17.0.1 react-dom@^17.0.1 --legacy-peer-deps

All 2 comments

Thanks for the issue. The problem here is that your application likely has React 16 installed; however, use_referred_state requires React 17. This resulted in both React 16 and React 17 being installed (See Error 3 in the screenshot).

This is not really an Ionic Framework bug, but more of a dependency mismatch in your application. This does not happen in a CRA app since the latest CRA apps likely ship with React 17. That being said, I have relaxed the peer dependency requirement for Ionic React in https://github.com/ionic-team/ionic-framework/pull/22645 to accommodate some changes to npm 7. This relaxed requirement should be available in an upcoming release of Ionic Framework.

For now, I recommend installing React 17 manually:

npm install react@^17.0.1 react-dom@^17.0.1 --legacy-peer-deps

Thanks it works !

Was this page helpful?
0 / 5 - 0 ratings