Comments (7)
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.
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.
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.
@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.
@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.
@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.
Something is causing it to render projects again and again is there a possibility of circular dependency here
from todoist.
Related Issues (20)
- delete projects modal style is broken HOT 1
- onKeyDown and tabbing through elements conflict HOT 2
- when i run npm start appear some question, what can do to resolve this question HOT 2
- Firebase.firestore is not a function HOT 3
- in project not showing options HOT 3
- Project license HOT 1
- No firebase module? HOT 2
- projects not appearing on screen
- projects not appearing on screen open HOT 1
- Stylying of Individual Project component is messed up
- Cypress e2e tests
- sass incompatible HOT 2
- Stylesheet Issues
- unable to run code on local macine HOT 5
- Add prop-types HOT 1
- lastRandChars[i] in helpers should be undefined
- Feature Request : Add Options to archive tasks / todos HOT 4
- Is this project active?
- Wrap unit tests where necessary in Act HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from todoist.