Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite Renders on useCollection #95

Open
erayerdin opened this issue Oct 29, 2024 · 3 comments
Open

Infinite Renders on useCollection #95

erayerdin opened this issue Oct 29, 2024 · 3 comments
Assignees
Labels
severity|high The related issue causes to consume too much resources type|bug Something isn't working

Comments

@erayerdin
Copy link
Owner

No description provided.

@erayerdin erayerdin added the type|bug Something isn't working label Oct 29, 2024
@erayerdin erayerdin self-assigned this Oct 29, 2024
@erayerdin erayerdin added the severity|high The related issue causes to consume too much resources label Oct 29, 2024
@erayerdin
Copy link
Owner Author

@erayerdin
Copy link
Owner Author

This below seems like it solves the issue, experimenting with it:

const colRef = useMemo(() => collection(firestore, 'signupRequests'), [firestore]);
const colQuery = useMemo(() => query(colRef, limit(25), orderBy('requestDate', 'desc')), [colRef]);
const [snapshot, setSnapshot] = useState<QuerySnapshot<DocumentData, DocumentData> | undefined>();

@erayerdin
Copy link
Owner Author

So, wrapping Firestore, CollectionReference and CollectionQuery instances with useMemo gets rid of the rerender.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity|high The related issue causes to consume too much resources type|bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant