My application uses angularJS, so I'm migrating it to React. I'm navigating to a route: /index like this $urlServiceProvider.rules.otherwise('/index').Note that I'm using angularJS's urlServiceProvider to navigate to /index which has $stateProvider set like this :
$stateProvider.state('index', {
component: AppController,
url: '/index',
template: `<div id="application"></div>`
})
// AppController.jsx
import * as ReactDOM from 'react-dom'
import * as React from 'react'
import App from './App'
export class AppController implements ng.IComponentController {
constructor() {}
$onInit(): void {
ReactDOM.render(<App />, document.getElementById('application'))
}
}
<App /> component is a component in react which has routes defined for every page.
Now, this works fine but what If I want to set queryString params, which I did it like this: /index?redirect=true. Now, inside <App /> component if I log the value like:
// App
const { redirect } = useLocation()
console.log('Redirect value is ', redirect) // Expecting true here
I get nothing printed in console. Am I doing it correct here?
useLocationhook here? Is it theuseLocationhook fromreact-router-dom? What version ofreact-router-domdo you have installed?useLocationhook from react-router-dom v6