How to create a new tab from a router?
Given an index.tsx:
ex.
import { Route, Routes } from "react-router-dom"
import { Login } from "~newtab/login"
export const Routing = () => (
<Routes>
<Route path="/newtab/login" element={<Login />} />
</Routes>
)
that is mapped from the popup.tsx as follows:
import { Routing } from "~routes"
import React from "react";
function IndexPopup() {
return (
<Routing />
)
}
export default IndexPopup
How can i get my first login route to create a new tab?
1 Reply
update: I was able to use useLocation to solve this:
export const Routing = () => {
const location = useLocation();
useEffect(() => {
if (location.pathname === "/") {
openLoginTab();
}, [location]);
const openLoginTab = () => {
chrome.tabs.create({url: 'chrome-exension://{x}/newtab/login'});
};
where the routes are the same as above
hovever; now I am facing an issue where the new tab is blocked by brave browser. There is nothing but straight jsx on the login page (no api call or anything); how could i solve this?