Is there a way to programmatically navigate using Reach Router in React? I have noticed that when updating the URL, the route does not render. Even though the URL changes, the original component remains displayed according to the React developer tools.
However, upon refreshing the page at the new URL, the correct route is rendered.
How can I ensure that the new route is rendered without having to refresh?
Below is a simplified example of my code implementation, utilizing @reach/router
(note that I am also using Redux):
import React from 'react';
import { navigate } from '@reach/router';
const ExampleComponent = props => {
navigate('/a/different/url');
return <div />;
};
export default ExampleComponent;