Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

156
Vistas
Show loading icon before first react app initialization

What is the standard way of showing a loader icon before browser downloads all js files and loads react application.

Can I do something like this without breaking anything?

<div id="content" class="app">
  Loading...
</div>
over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Yes.

Once your javascript has loaded, you can replace Loading... by rendering your react app into the same <div>

render(
  <App />, 
  document.getElementById('content')
);
over 4 years ago · Santiago Trujillo Denunciar

0

One way of doing this using component life cycle methods.

class App extends React.Component {
    constructor(props){
      super(props);
      this.state = {
        loading: true
      };
    }
  
    componentWillMount(){
       this.setState({loading: true}); //optional 
    }

    componentDidMount(){
        this.setState({loading: false}) 
    }
  
    render() {
        return (
            <section className="content">
              {this.state.loading && 'loading...'} {/*You can also use custom loader icon*/}
              <p>Your content comes here</p>
              {this.props.children}
            </section>
        );
    }
}

ReactDOM.render(<App />, document.getElementById("app"));
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="app">
  
</div>

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda