reactjsreact-hooksreact-suspense

Module '"react"' has no exported member 'SuspenseList'. TS2305


I'm trying to learn some of the new features in React 18, such as the SuspenseList and new useId hook, but I seem to be getting the same error over and over:

Module '"react"' has no exported member 'SuspenseList'.  TS2305

This is what my package.json looks like:

  "dependencies": {
    "bootstrap": "^5.1.1",
    "history": "^5.0.1",
    "react": "^18.0.0-rc.0",
    "react-dom": "^18.0.0-rc.0",
    "react-error-boundary": "^3.1.3",
    "react-router-dom": "^6.0.0-beta.5",
    "swr": "^1.0.1",
    "web-vitals": "^1.1.2"
  },
  "devDependencies": {
    "@testing-library/jest-dom": "^5.14.1",
    "@testing-library/react": "^11.2.7",
    "@testing-library/user-event": "^12.8.3",
    "@types/jest": "^26.0.24",
    "@types/node": "^12.20.27",
    "@types/react": "^17.0.37",
    "@types/react-dom": "^17.0.9",
    "prettier": "^2.4.1",
    "react-scripts": "4.0.3",
    "typescript": "^4.4.3"
  },

I have no clue what to do at this point, as I've installed the RC version of React 18, which should be the latest according to the Working Group GitHub discussion board.


Solution

  • If anyone is still facing this issue Please install the latest version of @types/react More info in the attached npm link npm i @types/react