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

153
Visualizações
How to implement deeplinks for react project?

I was trying to implement deep links(not sure if this is the correct term) in my react project what I want to do is this :

  1. the admin gets a mail: "this user can't login: http://localhost:3000/admin/customer-profile/b1d4a11f-4f6c-4dc1-98a9-ac0c30486c16"

  2. the admin is not logged in

  3. the admin clicks the link and is forwarded to the login page

  4. the admin enters his login details

(the new part)

  1. he is forwarded to /admin/customer-profile/b1d4a11f-4f6c-4dc1-98a9-ac0c30486c16

so in the fifth point the admin is redirected to the page link was for instead of going to the homepage.

Below are some snippets to give more info regarding this:

    <div className="App">
      {ready && <Router basename="/admin">

        <Switch>
          <Route path="/login">
            <Login />
          </Route>
          <Route path="/privacypolicy">
            <PrivacyPolicy />
          </Route>
          <Route path="/loginhelp">
            <Help />
          </Route>
          <Route path="/termsconditions">
            <TermsConditions />
          </Route>
          <PrivateRoute path="/logout">
            <Logout />
          </PrivateRoute>

          <Route path="/">
            <SideBar />
            <Switch>
              <PrivateRoute path="/tier-list">
                <TierList />
              </PrivateRoute>
              <PrivateRoute path="/privacy-policy">
                <PrivacyPolicy />
              </PrivateRoute>
              <PrivateRoute path="/help">
                <Help />
              </PrivateRoute>
            </Switch>
          </Route>
        </Switch>
      </Router>}
    </div>

Below is how PrivateRoute looks like :

  function PrivateRoute({ children, ...rest }: any) {
    return (
      <Route
        {...rest}
        render={({ location }) =>
          userInfo != null ? (
            children
          ) : (
            <Redirect
              to={{
                pathname: "/login",
                state: { from: location }
              }}
            />
          )
        }
      />
    )
  }

Any ideas How I shall modify this part to achieve the functionality?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Okay so I solved the problem. What I did was that I passed a pathName prop to the Login component and then if the user was logged in I redirect him to that page but if not then rendered the login page.

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