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: Property 'Reflect' doesn't exist on ReactNative Android #303

Closed
ShivamJoker opened this issue Dec 4, 2020 · 5 comments · Fixed by #304
Closed

ReferenceError: Property 'Reflect' doesn't exist on ReactNative Android #303

ShivamJoker opened this issue Dec 4, 2020 · 5 comments · Fixed by #304

Comments

@ShivamJoker
Copy link
Contributor

Versions
"ky": 0.25,
"react-native": "0.63.4"

Works fine on iOS

/** Handle the otp generation on forgotPassword */
export const sendOTP = async (email) => {
  try {
    const res = await ky
      .post(`${userAPIURL}/users/forgotPassword`, {
        json: {email: email},
      })
      .json();
    return {success: true, message: 'OTP sent to email'};
  } catch (error) {
    console.log(error);
    const errMsg = await error.response.json();

    // console.log(errMsg);
    return {success: false, message: errMsg.description};
  }
};
@ComputerWolf
Copy link

If you have hermes enabled in react native it does not support Reflect.

You will need to polyfill Reflect.has which is the method that ky uses.

I did this using core-js by including import 'core-js/es/reflect/has'; as the first line in my entry file.

@szmarczak
Copy link
Collaborator

The very first paragraph of Ky:

Ky targets modern browsers and Deno.

@sholladay
Copy link
Collaborator

Personally, I prefer using the in operator instead of Reflect.has(), anyway. I'm fine with changing it if the rest of the team is, too.

@szmarczak
Copy link
Collaborator

I'm +1

@sindresorhus
Copy link
Owner

Sure

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

Successfully merging a pull request may close this issue.

5 participants