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

118
Visualizações
Render HTML of embed-deployed Component

I want to integrate my react app to a 3rd party app which enables me to put a script that appends the elements into the html.

But it appears that it is not that straightforward in react. The script does not append the elements so my custom component does not appear on the page.

This is what I am trying to do ( but not a gist ):

function Snippet){
    
    return (
        <Wrapper>
            <h1> Snippet 1</h1>
            <script src="https://gist.github.com/xxxx/e4208e452e32e353b6076944c80a1058.js"></script>
        </Wrapper>
    )
}

Is there a way to do this with just react?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Hi Going back to this inquiry, I found an npm package that enables the embedding of github gist in a react component.

Following the implementation of the Gist Component in the package, we can also deploy the code programmatically instead of pasting the deployment script directly to the component and it will work just fine.

export default class DeployedComponent extends React.Component{
constructor(props){
    super(props);
}

componentDidMount(){
    (function(props,doc,elementName,id){
        let jsElement;
        if(doc.getElementById(id)){
            return;
        }
        jsElement = doc.createElement(elementName);
        jsElement.id = id;
        jsElement.src= "deployment_script_src";
        doc.getElementsByClassName("cb-deployment-wrapper")[0].appendChild(jsElement);


    })(this.props, document,"script","script_id");
}


render(){
    return (
        <div className="w-100 cb-deployment-wrapper ">
        </div>
    );
}
}
about 4 years ago · Juan Pablo Isaza 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