Skip to content

Android padStart is undefined, likely needs to be polyfilled #18375

@callmetwan

Description

@callmetwan

When testing on Android 5.0+ (Google API 22+) I found that calls to padStart would result in "undefined is not a function". Polyfilling it manually resolved the issue in Android 5.0+. My polyfill fix was a verbatim copy/paste of the polyfill example on MDN's padStart . This error does not happen when debugging remotely. If my understanding is correct, this is due to differences in Chrome's JS engine vs React Natives implementation.

I found related issue #17442 where this error was occurring on iOS. I opened a separate issue because this was happening on Android.

Environment

#####Environment:
OS: macOS Sierra 10.12.6
Node: 9.5.0
Yarn: Not Found
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.0 AI-171.4443003

#####Packages: (wanted => installed)
react: ^16.2.0 => 16.2.0
react-native: ^0.53.3 => 0.53.3

Expected Behavior

Calls to padStart should return a value according to MDN

Actual Behavior

Calls to padStart result in an error of "undefined is not a function"

Steps to Reproduce

Call padStart on a string.

const test = 'hello'
console.log(test.padStart(2, '0')) // results in 'undefined is not a function'

Reproducible Demo

https://snack.expo.io/ByAN82Itz

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugPlatform: AndroidAndroid applications.Ran CommandsOne of our bots successfully processed a command.Resolution: LockedThis issue was locked by the bot.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions