There are times when you’ll want some code to navigate the user to another location — even if they haven’t just clicked a
<Link>. In cases like this, you’ll need to call
navigate() on your app’s navigation object. And to get the navigation object, you can just call the
For example, here’s how you could programmatically navigate the user after they’ve submitted a form:
navigation.navigate() function returns a promise to the
Route object of the new URL. This makes it perfect for use in form submit handlers that expect a promise as a return — like react-final-form.
Here’s another form handling example, but this time using react-final-form, and POSTing the form result to a