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

175
Visualizações
React route with chrome.runtime.getURL

I am trying to build a chrome extension using reactjs and I realized that route is not working as expected,

What i am trying to do is the following:

  • adding a button having a click event
  • onclick the button should open the login page inside a pop up window using window.open
  • use Route do defined which component should be opened inside the popup window

this is my code

 /* eslint-disable react/jsx-no-undef */
/* eslint-disable no-undef */
/*global chrome*/
import React from "react";
import { Router, Route, Routes, Link } from 'react-router-dom';
import { createBrowserHistory } from "history";
import login from "./login";
 class App extends React.Component {
     popupwindow = (url, title, w=500, h=500) => {
       var left = screen.width / 2 - w / 2;
    var top = screen.height * 0.1;
    return window.open(
        url,
        title,
        "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=" +
        w +
        ", height=" +
        h +
        ", top=" +
        top +
        ", left=" +
        left
    );
}
render() {
    const history = createBrowserHistory();
    return (
        <div>
            <button onClick={()=>this.popupwindow(chrome.runtime.getURL("/login"),"login")}>Twitter</button>
            <Router  location={history.location} navigator={history}>
                <div>                       
                    <Routes>
                        <Route path="/" exact element={<login />} />
                        <Route path="/login" exact element={<login />} />
                    </Routes>
                </div>
            </Router>
        </div>
    );
  }
};
export default App;

screenshot

enter image description here

my manifest already contains this section

  "web_accessible_resources": [{
   "resources": ["*.png"],
   "matches": ["<all_urls>"]
 },
 {
   "resources": ["*.html"],
   "matches": ["<all_urls>"]
 },
 {
   "resources": ["*.js"],
   "matches": ["<all_urls>"]
}], 

Does anyone know how to solve this? thank you

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