Skip to content
Advertisement

How to allow async functions in React + Babel?

I have a Typescript/React app, that can perform async function with a then/catch promise, but not with async/await/try/catch.

The error is: Uncaught ReferenceError: regeneratorRuntime is not defined .

The error seems to come from Babel. Here is my config:

JavaScript

How to fix this?

Advertisement

Answer

You can find your solution at here

If I summarise then you have to install a babel plugin named plugin-transform-runtime and need to configure the .babelrc settings.

JavaScript

After installing these two go to the .babelrc file and add these plugins.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement