javascript - 'react-router' does not contain an export named 'Link' - Stack Overflow


本站和网页 https://stackoverflow.com/questions/44267049/react-router-does-not-contain-an-export-named-link 的作者无关,不对其内容负责。快照谨为网络故障时之索引,不代表被搜索网站的即时页面。

javascript - 'react-router' does not contain an export named 'Link' - Stack Overflow
Stack Overflow
About
Products
For Teams
Stack Overflow
Public questions & answers
Stack Overflow for Teams
Where developers & technologists share private knowledge with coworkers
Talent
Build your employer brand
Advertising
Reach developers & technologists worldwide
About the company
s-popover#show"
data-s-popover-placement="bottom-start" />
Loading…
current community
Stack Overflow
help
chat
Meta Stack Overflow
your communities
Sign up or log in to customize your list.
more stack exchange communities
company blog
Log in
Sign up
Home
Public
Questions
Tags
Users
Companies
Collectives
Explore Collectives
Teams
Stack Overflow for Teams
– Start collaborating and sharing organizational knowledge.
Create a free Team
Why Teams?
Teams
Create free Team
Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
'react-router' does not contain an export named 'Link'
Ask Question
Asked
5 years, 6 months ago
Modified
5 years, 1 month ago
Viewed
46k times
26
I'm using react-router@4.1.1
└─┬ react-router@4.1.1
├─┬ history@4.6.1
│ ├── resolve-pathname@2.1.0
│ └── value-equal@0.2.1
└── warning@3.0.0
and this message appears in development when attaching a react-router Link
./src/containers/FilterLink.js
37:4-8 'react-router' does not contain an export named 'Link'.
This is the import code:
import React from 'react';
import { Link } from 'react-router';
By the way changing version to react-router@2.0.1 seems to be working.
Does anyone know if Link was removed from react-router? what happened with Link?
If not, why do I get this error?
javascriptreactjsreact-router
Share
Improve this question
Follow
edited May 30, 2017 at 16:09
Evhz
asked May 30, 2017 at 16:06
EvhzEvhz
8,55688 gold badges5050 silver badges6868 bronze badges
Add a comment
1 Answer
Sorted by:
Reset to default
Highest score (default)
Trending (recent votes count more)
Date modified (newest first)
Date created (oldest first)
72
4.x introduced some breaking changes, you'll need to import Link from react-router-dom:
CommonJS
var Link = require('react-router-dom').Link
ES6 Modules
import { Link } from 'react-router-dom'
Take a peek here for some additional background: https://github.com/ReactTraining/react-router/tree/master/packages/react-router-dom
Share
Improve this answer
Follow
edited Nov 1, 2017 at 14:52
answered May 30, 2017 at 16:08
luxlux
8,21977 gold badges3434 silver badges4949 bronze badges
does it provide any side effect when combined with browserHistory from react-router?
– Evhz
May 30, 2017 at 16:12
@Karlos If you do something like <Link to={browserHistory.push('/foo')}>, that will most likely have to change. They really did completely rewrite 4.x - have a look here: stackoverflow.com/questions/42701129/…
– lux
May 30, 2017 at 16:17
I see router 4.x breaks rendering flow with react-dom render, even if using Router, Route from react-router-dom. I would like to minimize the refactoring of the code for this change, so decide whether to use 4.x with compatible versions of react-dom or just keep using react-router < 4.x
– Evhz
May 30, 2017 at 16:24
@Karlos Clicked the chat by accident, feel free to disregard. And I think that's a safe call, AFAIK, they will be supporting 3.x indefinitely, so upgrading to 4.x is not at all required.
– lux
May 30, 2017 at 16:30
Don't forget to install the react-router-dom package instead of react-router: npm install --save react-router-dom
– Joshua Pinter
May 17, 2018 at 22:19
Show 4 more comments
Your Answer
Thanks for contributing an answer to Stack Overflow!Please be sure to answer the question. Provide details and share your research!But avoid …Asking for help, clarification, or responding to other answers.Making statements based on opinion; back them up with references or personal experience.To learn more, see our tips on writing great answers.
Draft saved
Draft discarded
Sign up or log in
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Submit
Post as a guest
Name
Email
Required, but never shown
Post as a guest
Name
Email
Required, but never shown
Post Your Answer
Discard
By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy
Not the answer you're looking for? Browse other questions tagged javascriptreactjsreact-router or ask your own question.
The Overflow Blog
I spent two years trying to do what Backstage does for free
The complete guide to protecting your APIs with OAuth2 (part 1)
Featured on Meta
Navigation and UI research starting soon
2022 Community Moderator Election Results - now with two more mods!
Temporary policy: ChatGPT is banned
I'm standing down as a moderator
Linked
480
How to push to History in React Router v4?
16
How do I determine the most popular version of a given npm package?
Related
3151
Why does my JavaScript code receive a "No 'Access-Control-Allow-Origin' header is present on the requested resource" error, while Postman does not?
378
react-router - pass props to handler component
1148
React-router URLs don't work when refreshing or writing manually
2151
Programmatically navigate using React router
432
React Router with optional path parameter
React Router <redirect> not working
480
How to push to History in React Router v4?
261
React-Router External link
383
How to pass params with history.push/Link/Redirect in react-router v4?
'react-router-dom' does not contain an export named 'useHistory'
Hot Network Questions
how many moves does it take a knight to move 1 square forward
Replace all vowels with repeated "aeiou"
What does it mean by "maximum likelihood estimation (MLE) problem is unbounded"?
Why are wire transfers not reversible by the bank?
Why is this position -6.2 without a big material difference?
How to Give an Elliptical Border a Braided Effect
Has Zelensky has "declared war against Christianity"?
Protecting gingerbread house windows from humidity
Spin the wheel game
Why can't I do two greps after a tail?
Bathroom and dining room reversal
How to find online touristic information, the kind we should not ask for on this site?
What are good heat-resistant materials for writing a self-immolating spellbook?
How does the kernel know it's resuming from hibernation, not booting?
Can a US citizen be held by US immigration due to a lack of passport stamps?
Replace 0s In a String With Their Consecutive Counts
Table row to fill entire page
Where would the first nuke have been dropped in Germany?
What happens if a US president is found to have engaged in insurrection after taking office?
Does the set of square numbers adhere to Benford's law in every base?
DM is taking too much time in my opinion on side missions - should I leave?
Security Clearance - How do I explain that I lived in a "problem" country while working remotely?
What does a lobbyist offer a politician?
Did the crew lock themselves inside the LM on Apollo 13?
more hot questions
Question feed
Subscribe to RSS
Question feed
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
lang-js
Stack Overflow
Questions
Help
Products
Teams
Advertising
Collectives
Talent
Company
About
Press
Work Here
Legal
Privacy Policy
Terms of Service
Contact Us
Cookie Settings
Cookie Policy
Stack Exchange Network
Technology
Culture & recreation
Life & arts
Science
Professional
Business
API
Data
Blog
Facebook
Twitter
LinkedIn
Instagram
Site design / logo 2022 Stack Exchange Inc; user contributions licensed under CC BY-SA. rev 2022.12.21.43127
Your privacy
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
Accept all cookies
Customize settings