D
D
Dmitry Markov2022-02-02 17:26:46
React
Dmitry Markov, 2022-02-02 17:26:46

React route history?

There are 3 routes: the page of all partners, the page of a certain category of partners and the view partner

<Route exact path='/partners/' component={AllPartners} />
<Route exact path='/partners/:idCat' component={AllPartners} />
<Route exact path='/partner/:id' component={PartnerView} />

How can I find out on the PartnerView page from which route I got there?)

My task is to implement a back button on the partner's view. But you can't use history.goBack because can be accessed via a direct link.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikolai Turnaviotov, 2022-02-02
@foxmuldercp

pass ?backpage='frompage' when called. so that it gets into the list of parameters when clicking on the link. as is usually done in advertising and one-page

A
Aetae, 2022-02-03
@Aetae

Just hang the handler on history.listenand use the handles to write the previous value somewhere (in sessionStore, for example, for reliability). You can take the very first one document.referrer(if there is one and if it leads to your site by itself).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question