0

The desired effect when submitting a form using React router 4 is to append the search query to the end of the URL.

My current setup will send an API request on form submission, and then render the results in the render method.

Without using Links or Redirects, is there a way to add the query onto the URL, maybe from within the form submission method?

1
  • 1
    You could use the history object in your submission function. Check out if this previous question to see if it's what you're looking for: stackoverflow.com/questions/42672842/… Commented May 22, 2017 at 9:12

1 Answer 1

1

You can dynamically push the queries to the url like

this.props.router.push({
  pathname: '/yourRoute',
  query: { someQuery: 'value' }
})

Connect your Component with witRouter to be able to use the router prop

import { withRouter } from 'react-router'

....


export default withRouter(App);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.