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

213
Vistas
What is causing my react page to be blank?

I don't know why my react page is blank. This started happening after I made a submit button that wouldn't refresh the page. This is the last file that I worked on and everything is compiling correctly. Here it is:

1st page: enter image description here

2nd page: enter image description here

This was last page I worked on and this is where my React page started to turn blank. Just let me know if there anything wrong with my click event. Here is my react blank page: enter image description here

code:

import { Avatar } from '@mui/material';
import React from 'react';
import './messageSender.css';

function MessageSender() {
  
    document.getElementById("submit").addEventListener("click", (event) => {
        event.preventDefault();
    });

    return (
    <div className="messageSender">
        <div className="messageSender__top">
            <Avatar />
            <form>
                <input 
                    className="messageSender__input"
                    placeholder={`What's on your mind?`}
                />
                
                <input  placeholder="Image URL (Optional)"/>

                <button id="submit" type="submit">
                    Hidden Submit
                </button>
            </form>
        </div>

        <div className="messageSender__bottom">

        </div>
    </div>
  )
}

export default MessageSender;
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Please include your code not as screenshoot.

In react, you can assign onSubmit directly to the form, using synthetic event is prefered way.

Synthetic Events is a React instance that all regular events go through in React.

React has created this to keep consistency for all browsers, and to increase performance since SyntheticEvent is pooled and also directly makes sure that once your component unmounts it removes eventListener.

So what I would do is I would add onSubmit to form and preventDefault in there.

<form onSubmit={(e) =>e.preventDefault()}></form>

The blankscren is propably because you did not include your eventListener in useEffect, hence it tries to addEvent to a null value.

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