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

151
Visualizações
When I was developing a Google plug-in, an error occurred during front-end and back-end interaction

I have a question when i dev chrome extensions use React this is the log handler in background.js and BackgroundConsole is no error the loggerList is async

interface ILog {
  date: string;
  level: 'debug' | 'info' | 'warn' | 'error';
  msg: string;
}  
static loggerList: string= []
static async loggerLists(log: ILog[]) {
    this.setLogList().then(async (res) => {
      await res
      console.log(res);
      chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
        if (request.type === 'log') {
          sendResponse({
            log: res
          })
        }
        return true
      })
    })
  };
  static async setLogList() {
    return new Promise((resolve, reject) => {
      resolve(this.loggerList)
    })
  }

this is the popup.js when i use callback receive args

  const [logList, setlogList] = useState([])
  chrome.runtime.sendMessage({
    type: 'log'
  }, res => {
    setlogList(res.log)
    console.log(res, res.log, '1111111111111');
    //PopupConsole is endless loop to console.log(res, res.log, '1111111111111')
  })

this is the new code with pupup.js

  const [logList, setlogList] = useState([])
  useEffect(() => chrome.runtime.sendMessage({ type: "log" }, res => {
    console.log(res);
    setlogList(res.log)
  }), [])
      <Modal title="Basic Modal" visible={isModalVisible} onOk={handleOk} onCancel={handleCancel}>
        {
          logList.map((val: any) => {
            { JSON.stringify(val) }
            // return (
            <>
              <p>{val.date}</p>
              <p>{val.level}</p>
              <p>{val.msg}</p>
              <p>{val}</p>
            </>
            // )
          })
        }
      </Modal>

this is show page

about 4 years ago · Juan Pablo Isaza
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