react-router-dom usenavigate is not a function
# general
g
react-router-dom usenavigate is not a function
d
I don’t know what context you’re encountering this but there are three things I’d look at to start with. 1 - what is in your package.json for your react app 2 - what does your import look like 3 - is your useNavigate being called within a
<Router />
/
<Routes />
g
I am going through all of the steps for the Notes app. When I did what was instructed on the page about adding react-router-bootstrap, everything stopped working.
As far as I know, I am not calling useNavigate at all
d
What is in your package.json
g
Copy code
{
  "name": "frontend",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.1",
    "@testing-library/react": "^12.1.2",
    "@testing-library/user-event": "^13.5.0",
    "react": "^17.0.2",
    "react-bootstrap": "^1.6.1",
    "react-dom": "^17.0.2",
    "react-icons": "^4.2.0",
    "react-router-bootstrap": "^0.26.0",
    "react-router-dom": "5.2",
    "react-scripts": "5.0.0",
    "web-vitals": "^2.1.2"
  },
  "scripts": {
    "start": "sst-env -- 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"
    ]
  },
  "devDependencies": {
    "@serverless-stack/static-site-env": "^0.55.1"
  }
}
d
Hmm that’s peculiar. So if you go back a step, and remove it, everything works again?
g
yes
d
so just the very act of installing it causes that?
Try installing 0.25 instead. That’s what I have in my notes project and it works just fine.
g
on this page
Copy code
<https://serverless-stack.com/chapters/adding-links-in-the-navbar.html>
if I undo all of the changes after the phrase
Copy code
Unfortunately, when you click on them they refresh
All is working again.
But if I do the steps after that phrase, it doesn't work at all and I get the error I started this thread with.
d
IMO - step one. install exactly .0.25 of react router bootstrap
then blow out your node_modules and reinstall
also, another thing is that if you can push your repo up to github so I can look I can maybe help
g
That fixed it
Thank you very much
possibly package.json line that says ^0.25.0 should just say 0.25.0
d
Sure no prob! What happened is that react-router 6 came out. So that is why I thought that may be the issue
Yeah I’m sure the gang would accept a PR for that.
FWWI, I hang out in the #help channel a lot and its a good community. You’ll likely get solid responses there
g
Thanks again
I shouldn't have frustratedly jacked with with it for 2 hours before I hit the Slack channel.
d
Story of my life hahahaha
I made a PR for that change Greg. At least the next person won’t run into it
a
Thanks for let me know that is not a function.
😂
g
You guys are great. I am a novice with sst, but man is it impressive.
a
Yes it is.
j
Thanks for the PR @Devin. Just merged it.