Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!