I am building a website using react. I have a url http://0.0.0.0:9000/courseware/course/6/content/programming/issues/lab/1 which shows a list of issues belonging to a lab of id 1.
When I click on an issue (eg, 22), I want the url to become http://0.0.0.0:9000/courseware/course/6/content/programming/issue/22.
I tried doing this
this.props.history.push({
pathname: "issue/" + this.state.issue.id
})
but then the url would become /programming/issues/lab/1/issue/22
I tried doing this
const history = useHistory();
history.goBack();
this.props.history.push({
pathname: "issue/" + this.state.issue.id
})
but there is a react hook error
Then I tried doing
this.props.history.goBack();
this.props.history.push({
pathname: "issue/" + this.state.issue.id
})
but this is navigating the page and the below push function doesn't work.
First, Am I dealing with the urls in right way? If yes, then How do I solve this problem?
I am assuming I have to use history to navigate between urls without actually reloading the page.
Thanks in Advance