Some JS engines that are targeted by React Native, particularly iOS 8 and, to a lesser extent, Android 6, are missing some of the new ES2015 functions and they may not be polyfilled by a typical build system.
This leads to errors that look like this:
Unhandled JS Exception: undefined is not a function (evaluating ‘Number.parseInt’)
npm install --save react-native-polyfill
To use the entire package and mutate the base objects, simply import or require the package:
If you only want the Array or Number polyfills, you can include just one:
If you just want a single function or you want to limit the number of changes to the base object, you can access the functions directly:
const includes = ;
Where available, this project has used the MDN polyfills or a close variation.
- normalize // Uses the unorm library for a polyfill
More information about this topic can be found at: http://mcculloughwebservices.com/2016/11/29/adding-support-es2015-number-methods/