Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

100
Visualizações
Firebase Reads Suddenly Spiked with 54k

I am just getting my feet wet with firebase and in initial development, suddenly I get an error:

FirebaseError: Quota exceeded.

For context, I'm building a simple blog in React. It's saying the my function read problem is at "getPosts()":

import { useEffect, useState } from 'react';
import { getDocs, collection } from 'firebase/firestore';
import { db } from '../firebase-config';
import './Home.css';

const Home = () => {
  const [postList, setPostList] = useState([]);
  const postCollectionRef = collection(db, 'posts');

  useEffect(() => {
    const getPosts = async () => {
      const data = await getDocs(postCollectionRef);
      setPostList(data.docs.map(doc => ({ ...doc.data(), id: doc.id })));
    };
    getPosts();
  });
  return (
    <div className="homePage">
      {postList.map(post => {
        return (
          <div className="post">
            <div className='postHeader'>
            <div className='post-title'><h1>{post.title}</h1></div>
            <div className='post-author'><h5>{post.author.name}</h5></div>
            </div>
            <div className='post-content'>{post.postText}</div>
          </div>
        );
      })}
    </div>
  );
};

export default Home;

So as I'm searching around the settings I find this graph that completely confounds me. Maybes someone can tell me what happened here.

Graph showing reads spiking 54k at once.

Is mapping over the data this way accumulated 50k reads at once somehow?

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

Your useEffect doesn't have a dependency array, so it will fire indefinitely. Add an empty dependency array at the end of your useEffect to only fire it on mount.

  useEffect(() => {
    (async () => {
      const { docs } = await getDocs(postCollectionRef);

      setPostList(docs.map(doc => ({ ...doc.data(), id: doc.id })));
    })();
  }, []);

Learn more about it here

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda