I'm using react-router v4 for a React app.
In a form, I want to add query parameters on the onSubmit action
My code looks like this:
class FiltroCuentasCorrientes extends Component {
...//Other stuff.
onSubmit(e) {
e.preventDefault();
const { someVariable, otherVariable } = this.state;
//Here I should add the variables to the query param.
}
render() {
<Form onSubmit={(e) => this.onSubmit(e)}>
...
</Form>
}
}
I don't know what the recommended approach is.
Should I have a variable in local state like shouldAddParam
and render a <Redirect />
with my params?
Or use the router
context and the navigateTo
method?
How can I do that?