2016-11-26 85 views
1

我的反應原生Firebase APL有一個奇怪的錯誤。類型NSnull的JSON值無法轉換爲NSString

react-native run-android工作正常,沒有錯誤。

但react-native run-ios失敗,並且類型爲NSnull的JSON值無法轉換爲NSString。

源代碼如下(主註冊類認證工作的火力)

我覺得火力地堡類對iOS和Android不同的ACT轉換JSON爲文本。

任何建議讚賞。

商事

主要

//這裏初始化火力應用程序,並根據需要將其傳遞到其他組件。只在啓動時初始化。

const firebaseApp = firebase.initializeApp(firebaseConfig); 

    var GiftedMessenger = require('react-native-gifted-messenger'); 

    let styles = {} 

    class Pricing extends Component { 

    constructor(props){ 

    super(props); 

    this.state = { 

    page: null 

    }; 

    /* this.itemsRef = this.getRef().child('items'); */ 

    } 

    componentWillMount(){ 

    // We must asynchronously get the auth state, if we use currentUser here, it'll be null 

    const unsubscribe = firebaseApp.auth().onAuthStateChanged((user) => { 

    // If the user is logged in take them to the accounts screen 

    if (user != null) { 

    this.setState({page: Account}); 

    console.log('(user != null)') 

    return; 

    } 

    // otherwise have them login 

    console.log('(user != Login)') 

    this.setState({page: Login}); 

    // unsubscribe this observer 

    unsubscribe(); 

    }); 

    } 

    render() { 

    if (this.state.page) { 

    return (

    // Take the user to whatever page we set the state to. 

    // We will use a transition where the new page will slide in from the right. 

    <Navigator 

    initialRoute={{component: this.state.page}} 

    configureScene={() => { 

    return Navigator.SceneConfigs.FloatFromRight; 

    }} 

    renderScene={(route, navigator) => { 

    if(route.component){ 

    // Pass the navigator the the page so it can navigate as well. 

    // Pass firebaseApp so it can make calls to firebase. 

    return React.createElement(route.component, { navigator, firebaseApp}); 

    } 

    }} /> 

); 

} else { 

return (

// Our default loading view while waiting to hear back from firebase 
+0

該錯誤似乎很具體。這個問題應該嘗試去做同樣的事情。 – user2864740

+0

CLASS firebase叫我的APL如下。 const firebaseApp = firebase.initializeApp(firebaseConfig); 常量退訂= firebaseApp.auth()。onAuthStateChanged((用戶)=> { this.props.firebaseApp.auth()。createUserWithEmailAndPassword( 常量的UserData = this.props.firebaseApp.auth()。 currentUser; 源= {{URI:this.state.user.photoURL}} /> //註銷,一旦完成後,用戶返回到登錄屏幕 this.props.firebaseApp。 auth()。signOut()。then(()=> { – itagaki

回答

0

我深深地調試了這個BUG。 最後我發現它如下。

<Image 
source={{uri: 'this.state.user.photoURL'}} <<<single quotation was added. 
style={styles.image} 
/> 

我沒有想到會有這樣的錯誤。

Thanks Shoji

+0

爲什麼ios和Android會在沒有單引號的情況下執行不同的操作? – itagaki

相關問題