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

274
Vistas
Webpack warning object from postmessage(React, typscript)

I'm working on a project(React, typescript) where first I want to create a new window by clicking a button, and send a message to the new window.

I can create a new window and send a postmessage but when I always open the new window then I got webpack warning objects and because of that I can't display the message what I sent in a html page.

webpack warning objects

Here my 2 ts files

ContainerWindow.tsx:

const ContainerWindow: React.FC = () => {

  const [recievedMessage, setRecievedMessage] = useState("");

  var popupWindow: Window | null;

  const sendMessage = () => {
    if (!popupWindow) return;
    popupWindow.postMessage("Hello", "http://localhost:3000");
  };

  useEffect(() => {
    window.addEventListener("message", function (e) {
      if (e.origin !== "http://localhost:3000") return;
      setRecievedMessage(e.data);
    });
  }, []);

  const openWindow = () => {
    popupWindow = window.open(
      "http://localhost:3000/customer-details/",
      "popupWindow",
      "width=500,height=500"
    );
    sendMessage();
  };

  return (
    <div className="App">
      <h1>Container Window</h1>
      <button onClick={openWindow}>Open Window</button>
    </div>
  );
}

export default ContainerWindow;

PopupWindow.tsx

const PopupWindow: React.FC = () => {
  const [recievedMessage, setRecievedMessage] = useState("");

  const sendMessage = () => {
    window.opener.postMessage("Hello back", "http://localhost:3000");
  };

  useEffect(() => {
    window.addEventListener("message", function (e) {
      if (e.origin !== "http://localhost:3000") return;
      if(e.data){
        setRecievedMessage(e.data);
      }
      console.log(e.data);
    });
    
  }, []);

  return (
    <div>
      <p>{recievedMessage}</p>
    </div>
  );
};

export default PopupWindow;

Can somebody help me to understand why is this happening?

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