Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

You should not use <Link> outside a <Router> #47

Closed
4 tasks done
OliverCole opened this issue Mar 17, 2019 · 6 comments
Closed
4 tasks done

You should not use <Link> outside a <Router> #47

OliverCole opened this issue Mar 17, 2019 · 6 comments

Comments

@OliverCole
Copy link

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • I am running the latest version
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed
  • I'm reporting the issue to the correct repository (for multi-repository projects)

Expected Behavior

Main page renders.

Current Behavior

Render error: You should not use <Link> outside a <Router>

The above error occurred in the <Link> component:
index.js:2178
    in Link (created by Router.Consumer)
    in Router.Provider (created by Router.Consumer)
    in Router.Consumer (created by Route)
    in Route (created by NavLink)
    in NavLink (at Sidebar.jsx:70)
    in li (at Sidebar.jsx:62)
    in ul (at Sidebar.jsx:57)
    in div (at Sidebar.jsx:56)
    in div (at Sidebar.jsx:33)
    in Sidebar (at Dashboard.jsx:106)
    in div (at Dashboard.jsx:104)
    in Dashboard (created by Router.Consumer)
    in Router.Provider (created by Router.Consumer)
    in Router.Consumer (created by Route)
    in Route (at index.js:18)
    in Router.Consumer (created by Switch)
    in Switch (at index.js:16)
    in Router.Provider (created by Router)

Seems similar to creativetimofficial/material-kit-react#25.

Failure Information (for bugs)

Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Get latest
  2. npm install
  3. npm start
  4. Load localhost:3000

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

Failure Logs

See above.

@terchris
Copy link

I have tried the same. I get the same result on:

Mac
Windows 10
Ubuntu 18.10
Ubuntu 18.04

@smwade
Copy link

smwade commented Mar 18, 2019

Ya, the strange thing is that it built with no errors a week ago. I have tried with several versions of npm with no luck. I also tried with the other react templates on creativetim and those also have this error. The only way I have been able to remove it is commenting out every <NavLink> component under the <Sidebar>

@OliverCole
Copy link
Author

Did you do an upgrade since? Would be super helpful to work out which package changed - as I think that’s probably the cause.

@smwade
Copy link

smwade commented Mar 18, 2019 via email

@einazare
Copy link
Contributor

Hello there, guys,

Thank you for your interest in working with our products.
Sorry for the late response, we do not work on weekends.
In our package.json file we only install "react-router-dom". This package auto-installs "react-router". The problem is that is installing the latest version of "react-router", instead of the same version as "react-router-dom", and that is why you are having this error.
Run the following command:

npm i -E react-router@4.2.2

And this will do the trick.

Best,
Manu

@smwade
Copy link

smwade commented Mar 18, 2019

Great thanks Manu! Thought I was going crazy. Just one thing, version 4.2.2 isn't on npmjs but 4.2.0 is and works great.

@einazare einazare closed this as completed May 2, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants