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

275
Visualizações
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 à 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