React Router: Cannot read property ‘pathname’ of undefined

I got the above error message and it was extremely cryptic. I tried the other solutions mentioned and it didn’t work.

Turns out I accidentally forgot to include the to prop in one of the <Link /> components.

Wish the error message was better. A simple required prop "to" not found or something like that would have been helpful. Hopefully this saves someone else who has encountered the same problem some time.

Leave a Comment