const mixer = (...arg) => arg.flat(9);
The error is: flat is not function
Why in react-native
it is not define but in browser works well?
My first guess is that the react-native
transpiler is not interpreting your ...arg
correctly, leading to an object that is not of Array
type. You are trying to call .flat
, which is a part of Array.prototype
. Since arg
could not be of type Array
, it is unable to find .flat
, thus leading to that error.
I am not certain though. Can you check the object type? You can use this code here below temporarily.
const mixer = (...arg) => { console.log(typeof arg); return []; }
What does it say? If it says Array
, then you might operate on a platform that does not support that function yet. Using a polyfill can solve your problem here.