I get a weird error when running my React Native app:
Some sample code:
const { url } = <incoming object>;
const reURL = <my regex>;
console.debug('url:', url);
console.debug('typeof url:', typeof url);
matches = [...url.matchAll(reURL)];
Log output:
url: <as expected>
typeof url: string
Error message:
TypeError: url.matchAll is not a function. (In 'url.matchAll(reURL)', 'url.matchAll' is undefined)
Everything works fine on iOS, the error only occurs on Android.
Pretty up to date environment, updated all npm
packages a couple of days ago.
Does anyone have the slightest idea where to even begin searching for a solution ?
You can use string.prototype.matchall
to polyfill.
https://www.npmjs.com/package/string.prototype.matchall
import matchAll from 'string.prototype.matchAll'
matchAll.shim()