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

ReferenceError: regeneratorRuntime is not defined with Create React App #39

Closed
Kerumen opened this issue Jul 27, 2017 · 4 comments
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@Kerumen
Copy link
Collaborator

Kerumen commented Jul 27, 2017

I tried to use react-pdf@2.0.0-beta with Create React App and I got this error.

Steps to reproduce:

npm install -g create-react-app
create-react-app test-pdf
cd test-pdf
npm install react-pdf@next --save
import React, { Component } from 'react';
import { Document, Page } from 'react-pdf'
import logo from './logo.svg';
import './App.css';

class App extends Component {
  render() {
    return (
      <div className="App">
        <Document>
          <Page />
        </Document>
      </div>
    );
  }
}

export default App;

I tried to install babel-polyfill and requires it before react-pdf but it didn't solve the issue.
It's mentionned in the README that babel-polyfill is required by the library if we don't use it but I didn't find where in the code?

@wojtekmaj
Copy link
Owner

Hey,
Thank you for this report! I'm not entirely sure what's going on there. babel-polyfill is required explicitly in components that need them (being e.g. Outline). Maybe I was wrong and, in fact, it is needed in another parts of the app? Would you please attach error stack?

@wojtekmaj wojtekmaj self-assigned this Jul 27, 2017
@wojtekmaj wojtekmaj added the bug Something isn't working label Jul 27, 2017
@wojtekmaj wojtekmaj added this to the 2.0.0 milestone Jul 27, 2017
@Kerumen
Copy link
Collaborator Author

Kerumen commented Jul 28, 2017

screen shot 2017-07-28 at 10 24 03

The best thing to do I guess it to require it once on top of your index.js file.

@Kerumen
Copy link
Collaborator Author

Kerumen commented Jul 28, 2017

See: https://stackoverflow.com/questions/36619383/referenceerror-regeneratorruntime-is-not-defined-but-working-inside-a-scope

Your functions and classes are hoisted, they exists before the require. To fix this, require babel-polyfill in your entry file.

@wojtekmaj
Copy link
Owner

Fixed by #41, thank you so much @Kerumen!

alexandernanberg pushed a commit to alexandernanberg/react-pdf that referenced this issue Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants