OGeek|极客世界-中国程序员成长平台

标题: android - NSnull 类型的 JSON 值无法转换为 NSString [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 18:10
标题: android - NSnull 类型的 JSON 值无法转换为 NSString

我的 react-native Firebase APL 有一个奇怪的错误。

react-native run-android 工作正常,没有错误。

但是 react-native run-ios 失败,NSnull 类型的 JSON 值无法转换为 NSString。

源代码如下。(主要和注册类在firebase上进行身份验证工作)

我认为 Firebase Class 在 ios 和 Android 上有不同的 ACT 来将 JSON 转换为文本。

任何建议表示赞赏。

商事

主要

//在此处初始化firebase应用,并根据需要将其传递给其他组件。仅在启动时初始化。

    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



Best Answer-推荐答案


我在这个BUG中深度调试。 最后找到如下。

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

没想到会出现这种错误。

谢谢庄司

关于android - NSnull 类型的 JSON 值无法转换为 NSString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40814806/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4