Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 29452

Type Error: u.slice is not a function. in index.android.bundle when I try to run a simple React Native app on android simulator

$
0
0

So I followed this video to build a simple Shopping List app using React Native:https://youtu.be/Hf4MJH0jDb4

It runs fine when I use react-native run-ios to get it running on the iOS simulator(actually some problems too, but I'm working on it), but when I try to run it using react-native run-android, a lot of problems arise.

1st problem, when the app does come up, I try to add an item, but after I press the "Add Item" button, this Type Error: u.slice is not a function. shows up.

enter image description here

so, as the problem code comes from index.android.bundle, I go there, and I have absolutely no idea what I am looking at and what I should do about it to fix the problem.

In case it helps, this is the 157th line of code where the Type Error occurs, is like:

__d(function(g,r,i,a,m,e,d){'use strict';var t=r(d[0]),n=t(r(d[1])),o=t(r(d[2])),l=t(r(d[3])),s=t(r(d[4])),u=t(r(d[5])),c=(function(){function t(){(0,n.default)(this,t)}return(0,o.default)(t,null,[{key:"alert",value:function(n,o,u,c){if('ios'===l.default.OS)t.prompt(n,o,u,'default');else if('android'===l.default.OS){if(!s.default)return;var f=s.default.getConstants(),p={title:n||'',message:o||'',cancelable:!1};c&&c.cancelable&&(p.cancelable=c.cancelable);var v=u?u.slice(0,3):[{text:"OK"}],y=v.pop(),b=v.pop(),h=v.pop();h&&(p.buttonNeutral=h.text||''),b&&(p.buttonNegative=b.text||''),y&&(p.buttonPositive=y.text||"OK");s.default.showAlert(p,function(t){return console.warn(t)},function(t,n){t===f.buttonClicked?n===f.buttonNeutral?h.onPress&&h.onPress():n===f.buttonNegative?b.onPress&&b.onPress():n===f.buttonPositive&&y.onPress&&y.onPress():t===f.dismissed&&c&&c.onDismiss&&c.onDismiss()})}}},{key:"prompt",value:function(t,n,o){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:'plain-text',c=arguments.length>4?arguments[4]:void 0,f=arguments.length>5?arguments[5]:void 0;if('ios'===l.default.OS){if('function'==typeof s){console.warn("You passed a callback function as the \"type\" argument to Alert.prompt(). React Native is assuming  you want to use the deprecated Alert.prompt(title, defaultValue, buttons, callback) signature. The current signature is Alert.prompt(title, message, callbackOrButtons, type, defaultValue, keyboardType) and the old syntax will be removed in a future version.");var p=s;return void u.default.alertWithArgs({title:t||'',type:'plain-text',defaultValue:n||''},function(t,n){p(n)})}var v,y,b=[],h=[];'function'==typeof o?b=[o]:Array.isArray(o)&&o.forEach(function(t,n){if(b[n]=t.onPress,'cancel'===t.style?v=String(n):'destructive'===t.style&&(y=String(n)),t.text||n<(o||[]).length-1){var l={};l[n]=t.text||'',h.push(l)}}),u.default.alertWithArgs({title:t||'',message:n||void 0,buttons:h,type:s||void 0,defaultValue:c,cancelButtonKey:v,destructiveButtonKey:y,keyboardType:f},function(t,n){var o=b[t];o&&o(n)})}}}]),t})();m.exports=c},151,[1,26,27,50,152,153]);

And when I try to reload the app, it says Could not connect to development server, although it still runs on iOS simulator perfectly fine.

enter image description here

I am absolutely a beginner on mobile app development and React Native, so there are a lot of things I don't know, and just trying to run the apps on simulators have caused me a lot of headaches.

Thank you in advance.


Viewing all articles
Browse latest Browse all 29452

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>