Answer the question
In order to leave comments, you need to log in
Map url by React-Router?
I have a search form with a url like localhost:3000/search? Keyword=xxx&subject=AAA&filter2=BBB etc. How do I create a react route for the URL so that the user can bookmark the search? My index.js code is below:
import { Route, Link, BrowserRouter as Router } from 'react-router-dom';
const routing = (
<Router>
<div>
<Route path="/" component={App} />
</div>
</Router>
)
ReactDOM.render(routing, document.getElementById('root'))
Answer the question
In order to leave comments, you need to log in
<Switch>
<Route exact path="/" component={App} />
<Route path="/search" component={Results} />
</Switch>
const Results = ({ location }) => {
const { search } = location;
// do something with search
return ( ... );
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question