Firebase sdk with react native unable to see anything












0














I am following this tutorial on RN with Firestore. I've so far only used the Firebase Web SDK installed via



npm install firebase -save


With the following example code:



constructor(props) {
super(props);
this.ref = firebase.firestore().collection('sessions');

this.unsubscribe = null;
this.state = {
dataSource: ,
loading: true,
};
}

componentDidMount() {

this.unsubscribe = this.ref.onSnapshot(this.onCollectionUpdate);

}

componentWillUnmount() {
his.unsubscribe();
}

onCollectionUpdate = (querySnapshot) => {
const dataSource = ;
querySnapshot.forEach((doc) => {

const { id, desc, zipcode, timestamp } = doc.data();
dataSource.push({
key: doc.id,
doc,
desc,
zipcode,
timestamp,
});
});
this.setState({
dataSource,
loading: false,
});
}


The above code returns absolutely nothing, even if I put a bogus collection name. Nothing runs, and I put a bunch of console.log statements but still can't see anything. I can't even tell if there is any problems connecting to Firestore.



I have not yet tried react-native-firebase module because I thought I am only doing a simple Firestore query, but at same time I am building my app natively on iOS on a Mac.



Am I supposed to be using the react-native-firebase module?










share|improve this question






















  • Yeah, would recommend using react-native-firebase. From their readme on github: "Although the official Firebase JS SDK will work with React Native; it is mainly built for the web and has a limited feature-set compared to native."
    – Kai
    Nov 21 at 0:42










  • Thanks, TBH I just need the most basic GET and SET, but if the SDK can't even provide that, obviously it cannot even be used.
    – user3786924
    Nov 21 at 2:40
















0














I am following this tutorial on RN with Firestore. I've so far only used the Firebase Web SDK installed via



npm install firebase -save


With the following example code:



constructor(props) {
super(props);
this.ref = firebase.firestore().collection('sessions');

this.unsubscribe = null;
this.state = {
dataSource: ,
loading: true,
};
}

componentDidMount() {

this.unsubscribe = this.ref.onSnapshot(this.onCollectionUpdate);

}

componentWillUnmount() {
his.unsubscribe();
}

onCollectionUpdate = (querySnapshot) => {
const dataSource = ;
querySnapshot.forEach((doc) => {

const { id, desc, zipcode, timestamp } = doc.data();
dataSource.push({
key: doc.id,
doc,
desc,
zipcode,
timestamp,
});
});
this.setState({
dataSource,
loading: false,
});
}


The above code returns absolutely nothing, even if I put a bogus collection name. Nothing runs, and I put a bunch of console.log statements but still can't see anything. I can't even tell if there is any problems connecting to Firestore.



I have not yet tried react-native-firebase module because I thought I am only doing a simple Firestore query, but at same time I am building my app natively on iOS on a Mac.



Am I supposed to be using the react-native-firebase module?










share|improve this question






















  • Yeah, would recommend using react-native-firebase. From their readme on github: "Although the official Firebase JS SDK will work with React Native; it is mainly built for the web and has a limited feature-set compared to native."
    – Kai
    Nov 21 at 0:42










  • Thanks, TBH I just need the most basic GET and SET, but if the SDK can't even provide that, obviously it cannot even be used.
    – user3786924
    Nov 21 at 2:40














0












0








0







I am following this tutorial on RN with Firestore. I've so far only used the Firebase Web SDK installed via



npm install firebase -save


With the following example code:



constructor(props) {
super(props);
this.ref = firebase.firestore().collection('sessions');

this.unsubscribe = null;
this.state = {
dataSource: ,
loading: true,
};
}

componentDidMount() {

this.unsubscribe = this.ref.onSnapshot(this.onCollectionUpdate);

}

componentWillUnmount() {
his.unsubscribe();
}

onCollectionUpdate = (querySnapshot) => {
const dataSource = ;
querySnapshot.forEach((doc) => {

const { id, desc, zipcode, timestamp } = doc.data();
dataSource.push({
key: doc.id,
doc,
desc,
zipcode,
timestamp,
});
});
this.setState({
dataSource,
loading: false,
});
}


The above code returns absolutely nothing, even if I put a bogus collection name. Nothing runs, and I put a bunch of console.log statements but still can't see anything. I can't even tell if there is any problems connecting to Firestore.



I have not yet tried react-native-firebase module because I thought I am only doing a simple Firestore query, but at same time I am building my app natively on iOS on a Mac.



Am I supposed to be using the react-native-firebase module?










share|improve this question













I am following this tutorial on RN with Firestore. I've so far only used the Firebase Web SDK installed via



npm install firebase -save


With the following example code:



constructor(props) {
super(props);
this.ref = firebase.firestore().collection('sessions');

this.unsubscribe = null;
this.state = {
dataSource: ,
loading: true,
};
}

componentDidMount() {

this.unsubscribe = this.ref.onSnapshot(this.onCollectionUpdate);

}

componentWillUnmount() {
his.unsubscribe();
}

onCollectionUpdate = (querySnapshot) => {
const dataSource = ;
querySnapshot.forEach((doc) => {

const { id, desc, zipcode, timestamp } = doc.data();
dataSource.push({
key: doc.id,
doc,
desc,
zipcode,
timestamp,
});
});
this.setState({
dataSource,
loading: false,
});
}


The above code returns absolutely nothing, even if I put a bogus collection name. Nothing runs, and I put a bunch of console.log statements but still can't see anything. I can't even tell if there is any problems connecting to Firestore.



I have not yet tried react-native-firebase module because I thought I am only doing a simple Firestore query, but at same time I am building my app natively on iOS on a Mac.



Am I supposed to be using the react-native-firebase module?







firebase react-native






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 at 23:34









user3786924

206




206












  • Yeah, would recommend using react-native-firebase. From their readme on github: "Although the official Firebase JS SDK will work with React Native; it is mainly built for the web and has a limited feature-set compared to native."
    – Kai
    Nov 21 at 0:42










  • Thanks, TBH I just need the most basic GET and SET, but if the SDK can't even provide that, obviously it cannot even be used.
    – user3786924
    Nov 21 at 2:40


















  • Yeah, would recommend using react-native-firebase. From their readme on github: "Although the official Firebase JS SDK will work with React Native; it is mainly built for the web and has a limited feature-set compared to native."
    – Kai
    Nov 21 at 0:42










  • Thanks, TBH I just need the most basic GET and SET, but if the SDK can't even provide that, obviously it cannot even be used.
    – user3786924
    Nov 21 at 2:40
















Yeah, would recommend using react-native-firebase. From their readme on github: "Although the official Firebase JS SDK will work with React Native; it is mainly built for the web and has a limited feature-set compared to native."
– Kai
Nov 21 at 0:42




Yeah, would recommend using react-native-firebase. From their readme on github: "Although the official Firebase JS SDK will work with React Native; it is mainly built for the web and has a limited feature-set compared to native."
– Kai
Nov 21 at 0:42












Thanks, TBH I just need the most basic GET and SET, but if the SDK can't even provide that, obviously it cannot even be used.
– user3786924
Nov 21 at 2:40




Thanks, TBH I just need the most basic GET and SET, but if the SDK can't even provide that, obviously it cannot even be used.
– user3786924
Nov 21 at 2:40












2 Answers
2






active

oldest

votes


















0














There is a typo error in your componentWillMount. componentWillUnmount() {
his.unsubscribe();
}



should be: componentWillUnmount() {
this.unsubscribe();
}



Also i recommend react-native-firebase.






share|improve this answer





















  • its there, I copied incorrectly, must have overwritten it while trying to format the code for code display. honestly my code is exactly like the tutorial minus a few elements in the doc
    – user3786924
    Nov 21 at 2:38



















0














So for anyone who found this with similar issues, just want to confirm that the Firebase Web SDK is indeed possible to be used for Firestore. There is no need to use react-native-firebase if your use case is very simple CRUD.



My error was that it was pulling the database content just that my render function was not displaying it.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53403207%2ffirebase-sdk-with-react-native-unable-to-see-anything%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    There is a typo error in your componentWillMount. componentWillUnmount() {
    his.unsubscribe();
    }



    should be: componentWillUnmount() {
    this.unsubscribe();
    }



    Also i recommend react-native-firebase.






    share|improve this answer





















    • its there, I copied incorrectly, must have overwritten it while trying to format the code for code display. honestly my code is exactly like the tutorial minus a few elements in the doc
      – user3786924
      Nov 21 at 2:38
















    0














    There is a typo error in your componentWillMount. componentWillUnmount() {
    his.unsubscribe();
    }



    should be: componentWillUnmount() {
    this.unsubscribe();
    }



    Also i recommend react-native-firebase.






    share|improve this answer





















    • its there, I copied incorrectly, must have overwritten it while trying to format the code for code display. honestly my code is exactly like the tutorial minus a few elements in the doc
      – user3786924
      Nov 21 at 2:38














    0












    0








    0






    There is a typo error in your componentWillMount. componentWillUnmount() {
    his.unsubscribe();
    }



    should be: componentWillUnmount() {
    this.unsubscribe();
    }



    Also i recommend react-native-firebase.






    share|improve this answer












    There is a typo error in your componentWillMount. componentWillUnmount() {
    his.unsubscribe();
    }



    should be: componentWillUnmount() {
    this.unsubscribe();
    }



    Also i recommend react-native-firebase.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 21 at 1:24









    Rafael Zerbini

    583




    583












    • its there, I copied incorrectly, must have overwritten it while trying to format the code for code display. honestly my code is exactly like the tutorial minus a few elements in the doc
      – user3786924
      Nov 21 at 2:38


















    • its there, I copied incorrectly, must have overwritten it while trying to format the code for code display. honestly my code is exactly like the tutorial minus a few elements in the doc
      – user3786924
      Nov 21 at 2:38
















    its there, I copied incorrectly, must have overwritten it while trying to format the code for code display. honestly my code is exactly like the tutorial minus a few elements in the doc
    – user3786924
    Nov 21 at 2:38




    its there, I copied incorrectly, must have overwritten it while trying to format the code for code display. honestly my code is exactly like the tutorial minus a few elements in the doc
    – user3786924
    Nov 21 at 2:38













    0














    So for anyone who found this with similar issues, just want to confirm that the Firebase Web SDK is indeed possible to be used for Firestore. There is no need to use react-native-firebase if your use case is very simple CRUD.



    My error was that it was pulling the database content just that my render function was not displaying it.






    share|improve this answer


























      0














      So for anyone who found this with similar issues, just want to confirm that the Firebase Web SDK is indeed possible to be used for Firestore. There is no need to use react-native-firebase if your use case is very simple CRUD.



      My error was that it was pulling the database content just that my render function was not displaying it.






      share|improve this answer
























        0












        0








        0






        So for anyone who found this with similar issues, just want to confirm that the Firebase Web SDK is indeed possible to be used for Firestore. There is no need to use react-native-firebase if your use case is very simple CRUD.



        My error was that it was pulling the database content just that my render function was not displaying it.






        share|improve this answer












        So for anyone who found this with similar issues, just want to confirm that the Firebase Web SDK is indeed possible to be used for Firestore. There is no need to use react-native-firebase if your use case is very simple CRUD.



        My error was that it was pulling the database content just that my render function was not displaying it.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 24 at 4:16









        user3786924

        206




        206






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53403207%2ffirebase-sdk-with-react-native-unable-to-see-anything%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            TypeError: fit_transform() missing 1 required positional argument: 'X'