I am using react router and I have the following code:
let history = useHistory();
let goToReviewPage = () => history.push(`review/${productId}`);
My current url is: /foo/bar
and calling goToReviewPage()
will redirect me to
/foo/review/${productId}
instead of /foo/bar/review/${productId}
I am not sure how to set the base path will pushing the history.
One way is to use window.location
to obtain the current path.
For example:
history.push(window.location.pathname + '/' + `review/${productId}`);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments