I'm pretty new to react router so I want to know whether the following scenario is possible or not.
I have two Routes. Detail Route & Listing Route. From Detail page I have a button "Add" which is suppose to open the Listing Route and on that route if use selects something I want to bring that back to Detail Route along with the user selected item.
I understand that using react router v6 I can do navigate(-1)
in list route to navigate back 1 page but the problem is that there is no way to return the selected item(unless I use store). Another approach is to use navigate('/detail-page', {state: {selectedItem}, replace:true)
which actually pass along the selected item. However, it also messes up the browser history and if I do navigate(-1)
from detail page it doesn't take user back to last page because last page is the detail page.