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

105
Visualizações
React script rendering iframe in certain browsers but not others

I am making a website for a business in React and I need to load widgets (bookeo) on some of the pages. I followed this Stack post and used the useScript() function to load the widgets:

import { useEffect } from 'react';

const useScript = url => {
  useEffect(() => {
    const script = document.createElement('script');

    script.src = url;
    script.async = true;

    document.body.appendChild(script);

    return () => {
      document.body.removeChild(script);
    }
  }, [url]);
};

export default useScript;

The hook is then implemented as such:

<Grid item xs={12}>
  {useScript("https://bookeo.com/widget.js?a=***************")}
</Grid>

It works on all versions of Mozilla, but only some Chrome browsers (based on OS), and no Microsoft Edge browsers. Widget's code is always received by client, but iframe is not rendered to DOM on said browsers. However, when the widget is simply implemented as a script tag in the index.html file, the widget works on all browsers with no problems, although the obvious problem is that I can't control it's location.

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