Giter VIP home page Giter VIP logo

Comments (7)

vp5h avatar vp5h commented on May 26, 2024 1
const allProjects = snapshot.docs.map((project) => ({
          name: project.data().name,
          userId: project.data().userId,
          projectId: project.data().projectId,
          docId: project.id,
        }));

This solves the RErendering as Stringify conditions work only when sequence is maintained, firestore is Sending data in random order at times, So avoid spread operaetor here would save 50k firebase calls for you.

from todoist.

karlhadwen avatar karlhadwen commented on May 26, 2024

Hey @apawn, so what happens here is that when useProjects is called, it goes ahead and makes a request to Firebase to get the data. If projects changes, it will re-run the useEffect so that's why I've added a JSON.stringify in there, so make sure it doesn't go into an infinite loop. If you call setProjects it will go ahead call Firebase again. Hopefully, that makes sense, if not let me know and I'll try my best to help :)

from todoist.

vuesomedev avatar vuesomedev commented on May 26, 2024

I also got confused here. Is it necessary to use .get and .onSnapshot also?
Handling Firebase like a Rest API, and maintaining a local state ignoring live changes would clarify it a lot.

from todoist.

karlhadwen avatar karlhadwen commented on May 26, 2024

@BlackSonic For this particular hook it does ignore live changes and just gets you a snapshot of what you have in the database.

from todoist.

apawn avatar apawn commented on May 26, 2024

@karlhadwen i mean here, it is not necessary to subscribe to the changes of firebase, we just use it for storage. and when calling useProject, you can save the data to firebase, and after that, update the state, which will cause UI update. when first time mounting the App Component, reading data from firebase.

from todoist.

karlhadwen avatar karlhadwen commented on May 26, 2024

@apawn you will see that it's not actually updating to firebase or subscribing listening to events, it takes a snapshot, unlike the tasks that are subscribing and listening for changes in tasks.

from todoist.

vp5h avatar vp5h commented on May 26, 2024

Something is causing it to render projects again and again is there a possibility of circular dependency here

from todoist.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.