oktaAuth in React - Error wrapping in Security

Hello

I am trying to add Okta Authentication and as soon as i wrap Security in Router tag /App.js I get following error

Error: Invariant failed: You should not use <withRouter(Security) /> outside a

I tried looking options for it, but nothing seems to be working

import { BrowserRouter as Router, Route } from “react-router-dom”;
import { Security, useOktaAuth } from “@okta/okta-react”;
import { OktaAuth } from “@okta/okta-auth-js”;

const config = {
clientId: “XXXXXXXXXXXX”,
issuer:
“XXXXXXXXXXXXXXXXXXXv1/token/”,
redirectUri: “http://XXXXXXlogin/callback”,
scopes: [“openid”, “profile”, “email”],
pkce: true,
};

const oktaAuth = new OktaAuth(config);

  <Security oktaAuth={oktaAuth}>

@monadeeps Hi, can you please help check your issuer? It should be sth like below instead of /token endopint.
issuer: ‘https://{yourOktaDomain}.com/oauth2/default’,

Thanks, yeah it is https://XXXXXXXXX/oauth2/default