skip to Main Content

Can anyone help me out to solve this problem.
As I am learning React Native, I was going through styled components but was facing an error related to styled components not compatible with react18 version. and same works in react@16 and below

I was trying to install styled-components for styling components in react-native. And i was receiving error saying that react18 is not compatible. I just want styled components to work

4

Answers


  1. Chosen as BEST ANSWER

    I sorted the solution as styled-component was not working for react 18.0.2.

    So I decided to uninstall react 18.0.2 by using npm uninstall [email protected] and then I reinstalled npm install [email protected] and then I read the documentation of Styled Component

    and installed styled-components using yarn add styled-components and successfully sorted out my problem.


  2. Try to install it with this command

    npm install styled-components --force
    
    Login or Signup to reply.
  3. npx expo install react-dom
    

    This fixed it for me (using expo managed react-native app)

    https://github.com/styled-components/styled-components/issues/3788#issuecomment-1335191911

    Login or Signup to reply.
  4. I had same problem when taking Udemy course about React Native. This course provides git with complete code, so what I did was:

    • Downloaded packages.json file from git url provided with course (last version),
    • Deleted my project node_modules folder,
    • Deleted my project packages-lock.json file,
    • Executed npm install
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search