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

replace() function works in VS Studio (React native), but fails on iPhone?

$
0
0

I have a function which works perfectly in Javascript on my iPhone simulator on the Mac. When i transfer this via Xcode to an physical iPhone handset, the .replace() function doesn't work. I get the error: TypeError: null is not an object (data.replace) not evaluating

await this.getAsyncStorage(this.state.username)
            .then(data => this.setState({localname: data.replace(/\"/g, "") }) );  

So i get a returned id ("hiuhiu22-sdwdw343-fgrh6576") from AsyncStorage when i supply the this.state.username key. The replace() strips "" off the ends of "hiuhiu22-sdwdw343-fgrh6576" to get just hiuhiu22-sdwdw343-fgrh6576, so that i can use localname in another function, which MUST have them stripped off.

Why isn't it working on the actual iPhone?


Viewing all articles
Browse latest Browse all 16750

Trending Articles



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