Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReferenceError: Can't find variable: regeneratorRuntime on React [closed]

I'm trying to creat a login with react and firebase. I've been following a tutorial, the problem is that this code:

const handleLogin = useCallback(
    async event => {
        event.preventDefault();
        const { email, password } = event.target.elements;
        try {
            await firebaseConfig.auth().signInWithEmailAndPassword(email.value, password.value);
            history.push("/citas")
        } catch (error) {
            alert(error);
        }
    },
    [history]
);

is giving me this error:

ReferenceError: Can't find variable: regeneratorRuntime

I don't find any solution as I don't know what it means. Any ideas?

like image 200
David Díaz Avatar asked Sep 17 '25 03:09

David Díaz


1 Answers

Using @babel/polyfill is officially deprecated. Since you are using a react application (and do not rely on a legacy codebase) you could prefer using the following:

npm i --save core-js/stable regenerator-runtime
// ECMA Script Polyfills:
import "core-js/stable";
// Needed for the generator functions which are transpiled from your async await keywords
import "regenerator-runtime/runtime";

Reference

like image 86
lotype Avatar answered Sep 19 '25 01:09

lotype