0

After user enters the search query in search box, i want the user to navigation to some other page, say "/market" component, with the search query, like this: https://localhost:8080/market?searchString=asdf. Can anyone please help me with this! I am not sure how to start with it.

<Search
              onKeyPress={(event) => {
                if (event.key === "Enter") {
                  this.onSearch(event.target.value);
                }
              }}
              placeHolderText= "Search"
              type="text"
            />

Method:

 onSearch(searchString) {
        if (searchString) {
          //performSearch
        }
      }
Singh
  • 207
  • 1
  • 5
  • 14
  • https://stackoverflow.com/questions/31079081/programmatically-navigate-using-react-router – Tim Gerhard Jun 26 '20 at 09:18
  • i dont see , they are passing param anywhere in above example. I want to pass the parameter along with navigating – Singh Jun 26 '20 at 09:22
  • https://stackoverflow.com/questions/61983051/multiple-param-with-react-router/61983141#61983141 – Dlucidone Jun 26 '20 at 09:24
  • can you help me with what to set in props to use this.props.history.push / this.props.router.push. Because i m getting, this.props.history is undefined in below code: interface props extends RouteComponentProps { history: RouteComponentProps.history;} – Singh Jun 26 '20 at 09:56
  • Have you wrapped your component with `withRouter` HOC? – Siddharth Jun 26 '20 at 14:42

0 Answers0