http://localhost:8080/?companyKey=eefef-edd-dd-ddf
I want to pass the company key in my react project via URL
I used this method
<Route exact path="/?companyKey=key"component={CompanySelectorFromKey} />
the method isn't working
http://localhost:8080/?companyKey=eefef-edd-dd-ddf
I want to pass the company key in my react project via URL
I used this method
<Route exact path="/?companyKey=key"component={CompanySelectorFromKey} />
the method isn't working
<Route path='/edit/:id' component={Edit} />
And in edit component you are received this id by
let id = props.match.params.id;
The way to pass parameters into a Route is like this <Route exact path="/:companyKey" component={CompanySelectorFromKey} />
Then in your CompanySelectorFromKey
, you can read that parameter like so:
const company_key = props.match.params.companyKey;
So your page would actually have to be accessed this way:
http://localhost:8080/eefef-edd-dd-ddf
Here is a working Sandbox: https://codesandbox.io/s/gracious-sky-jp8rv?file=/src/App.js
Try accessing the preview side like this:
https://jp8rv.csb.app/eefef-edd-dd-ddf
and you will see the magic.