Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Can't import the named export 'Action' #8221

Closed
paul-mesnilgrente opened this issue Nov 4, 2021 · 2 comments
Closed

Can't import the named export 'Action' #8221

paul-mesnilgrente opened this issue Nov 4, 2021 · 2 comments

Comments

@paul-mesnilgrente
Copy link

Version

6.0.0

Steps to reproduce

Install react-router and react-router-dom on rails react app using webpacker.

Create a component like this:

import { BrowserRouter, Route } from 'react-router-dom';
import { StaticRouter } from "react-router-dom/server";

const MyComponent = () => {
  const Router = inBrowser() ? BrowserRouter : StaticRouter;

  return (
    <Router>
      <Routes>
        <Route path="/users" />
        <Route path="/search" />
      </Routes>
    </Router>
  )
}

Expected Behavior

The component should work fine

Actual Behavior

Getting this compilation error:

ERROR in ./node_modules/react-router-dom/server.mjs 18:15-21
Can't import the named export 'Action' from non EcmaScript module (only default export is available)

I guess it's because of the webpacker configuration?

@timdorr
Copy link
Member

timdorr commented Nov 4, 2021

You probably have an older version of history installed. Install version 5.1.0 and you'll have the needed types.

@timdorr timdorr closed this as completed Nov 4, 2021
@paul-mesnilgrente
Copy link
Author

I checked my yarn.lock and I have

history@^5.1.0:
  version "5.1.0"
  resolved "https://registry.yarnpkg.com/history/-/history-5.1.0.tgz#2e93c09c064194d38d52ed62afd0afc9d9b01ece"
  integrity sha512-zPuQgPacm2vH2xdORvGGz1wQMuHSIB56yNAy5FnLuwOwgSYyPKptJtcMm6Ev+hRGeS+GzhbmRacHzvlESbFwDg==
  dependencies:
    "@babel/runtime" "^7.7.6"

Looks like you closed this issue way too quickly, without even waiting for a confirmation (feels a bit rude to be honest).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants