简体   繁体   English

'react-router'不包含名为'Link'的导出

[英]'react-router' does not contain an export named 'Link'

I'm using react-router@4.1.1 我正在使用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 连接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. 顺便说一下,将版本更改为react-router@2.0.1似乎正在运行。
Does anyone know if Link was removed from react-router? 有人知道Link是从react-router中删除的吗? what happened with Link? Link发生了什么?

If not, why do I get this error? 如果没有,为什么我会收到此错误?

4.x introduced some breaking changes, you'll need to import Link from react-router-dom : 4.x引入了一些重大更改,您需要从react-router-dom导入Link

CommonJS CommonJS的

var Link = require('react-router-dom').Link

ES6 Modules ES6模块

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 看看这里有一些额外的背景: https//github.com/ReactTraining/react-router/tree/master/packages/react-router-dom

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM