Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'react-router' does not contain an export named 'Link'

I'm using [email protected]

└─┬ [email protected]
  ├─┬ [email protected]
  │ ├── [email protected]
  │ └── [email protected]
  └── [email protected]

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 [email protected] 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?

like image 234
Evhz Avatar asked Sep 09 '25 16:09

Evhz


1 Answers

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

like image 77
lux Avatar answered Sep 12 '25 06:09

lux