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

123
Visualizações
React index.js in Django Project doesn't render imported components

I am trying to build a project with a hybrid architecture with Django as Backend and React as Frontend. For this I use Webpack and Babel to pipe the js files into djangos static index-bundle.js. However I encountered a problem which I don't understand. Apparently I can not import other components into my index.js react file. Instead, the root div stays empty.

While this works and the text is visible in the Browser...

ReactDOM.render(
    <h1> React in Django </h1>
    document.getElementById('root')
);

... importing it from another component doesn't work (div "root" has no inner elements)

ReactDOM.render(
    <App />,
    document.getElementById('root')
);

class App extends Component {
    render() {
        return (
            <h1>React in Django</h1>
        )
    }
}

In the end I want to have the "normal" react behaviour inside the django project.

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

0

Thanks to @jkarttunen answers in This Question I found the solution:

Turned out that the Problem was that Babel and React 17 require the setting "runtime":"automatic".

{
     "presets": [
         "@babel/preset-env",
        ["@babel/preset-react", {"runtime": "automatic"}]
     ]
}
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