1

i am using ionic-react and everything is going smooth but when i tried to use useState from react hooks, i ran into this problem:useState error What i have tried:

  1. Updating all packages to latest in Project folder using 'npm update'
  2. linking with react and react dom (first answer)
  3. Changing my package.json file.

The problem still presists.

The app works smoothly without using hooks, but it is much need and if there is an alternative to it, i can also use that.

NOTE: i did'nt explicitly created react library which is done in this question here i installed all dependencies using npm

This is my package json file:

{
  "name": "frontend-client-cpp",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "@ionic/react": "^5.6.5",
    "@ionic/react-router": "^5.6.5",
    "@testing-library/jest-dom": "^5.12.0",
    "@testing-library/react": "^11.2.5",
    "@testing-library/user-event": "^12.6.3",
    "@types/jest": "^26.0.20",
    "@types/node": "^12.19.15",
    "@types/react": "^16.14.3",
    "@types/react-dom": "^16.9.10",
    "@types/react-router": "^5.1.11",
    "@types/react-router-dom": "^5.1.7",
    "ionicons": "^5.4.0",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-router": "^5.2.0",
    "react-router-dom": "^5.2.0",
    "react-scripts": "4.0.2",
    "typescript": "^4.1.3",
    "web-vitals": "^0.2.4",
    "workbox-background-sync": "^5.1.4",
    "workbox-broadcast-update": "^5.1.4",
    "workbox-cacheable-response": "^5.1.4",
    "workbox-core": "^5.1.4",
    "workbox-expiration": "^5.1.4",
    "workbox-google-analytics": "^5.1.4",
    "workbox-navigation-preload": "^5.1.4",
    "workbox-precaching": "^5.1.4",
    "workbox-range-requests": "^5.1.4",
    "workbox-routing": "^5.1.4",
    "workbox-strategies": "^5.1.4",
    "workbox-streams": "^5.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "description": "An Ionic project"
}

1 Answers1

0

In your package.json, the dependency "@ionic/react-hooks" is missing, so install it: $ npm install @ionic/react-hooks

Ani
  • 121
  • 8