3

suppose I have a route path #/plugin?search=:q, and that query parameter q will be put into my search input box, that's okay. The question is if I change the content of my search input box, how can I make the change reflect in the URL path. Say if I type in react in the search inbox, then I want the URL path become #/plugin?search=react. Is this doable with react router?

Gelin Luo
  • 13,399
  • 23
  • 77
  • 119

2 Answers2

0

That would mean you need to create your routes manually, using Route.create method. then create a router instance to hold your routes on each render of your component. hope this idea helps.

Rei Dien
  • 176
  • 13
  • Sorry I didn't get you. Can you come up with some sample code? – Gelin Luo Jul 31 '15 at 04:57
  • ````var router = Router.create({ routes: 'your newly created path' location: Router.HistoryLocation });``` ```React.createClass({ handleUserInput(event) { this.setState({route: event.target.value}); }, render() { return } });``` – Rei Dien Jul 31 '15 at 05:18
0

this.props.params could help you.:q is a variable stored inside this.props.params of your component, you could access it and assigning it a value of your research (see react-router routeParams !).

Alex
  • 85
  • 1
  • 11