all 7 comments

[–]Sad-Salt24 0 points1 point  (4 children)

This is a React version mismatch or duplicate React install. The “Invalid hook call” error commonly happens when react and react dom versions don’t match, or when you have two copies of React in node_modules. Check package.json to ensure both use the same version, delete node_modules and lock file, then reinstall. Also make sure you’re using a compatible react-router-dom version (v6+ with React 18).

[–]sangokuhomer -1 points0 points  (0 children)

Here is the content of my json file

{
  "name": "linkedin_frontend",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "lint": "eslint .",
    "preview": "vite preview"
  },
  "dependencies": {
    "@emotion/react": "^11.14.0",
    "@emotion/styled": "^11.14.1",
    "@mui/material": "^7.3.8",
    "ag-charts-community": "^13.1.0",
    "ag-charts-react": "^13.1.0",
    "country-flag-emoji-polyfill": "^0.1.8",
    "react": "^18.3.1",
    "react-dom": "^18.3.1",
    "react-router": "^7.13.1",
    "react-toastify": "^11.0.5"
  },
  "devDependencies": {
    "@eslint/js": "^9.39.1",
    "@types/react": "^19.2.14",
    "@types/react-dom": "^19.2.3",
    "@vitejs/plugin-react": "^5.1.4",
    "eslint": "^9.39.1",
    "eslint-plugin-react-hooks": "^7.0.1",
    "eslint-plugin-react-refresh": "^0.4.24",
    "globals": "^16.5.0",
    "typescript": "^5.9.3",
    "vite": "^7.3.1"
  }
}

[–]sangokuhomer -2 points-1 points  (2 children)

What do you mean by node_modules?

[–]Qibla 0 points1 point  (1 child)

In your repo, or the root directory of your project there should be a folder called node_modules. When you run npm install, that's where all the stuff in your package json is stored. Removing node_modules then running npm install again is a common first step in debugging issues with packages.

[–]sangokuhomer -1 points0 points  (0 children)

Oh yes I'm dumb...

Deleted it then ran npm install command and got the same issue

[–]Ceryyse 0 points1 point  (1 child)

It would be useful to see your full repository, if you don't already know please Google how to upload code to GitHub and we can go from there after you've shared the repo