I followed the guide on routing with a Custom UI: https://developer.atlassian.com/platform/forge/add-routing-to-a-full-page-app/
The history.push()
calls work as expected: the app navigates to the new page and the URL is updated.
However, the value of history.location
doesn’t seem to update: it is always the value of the original URL entered in the browser, and doesn’t change following calls to history.push()
.
In my case I want to check the existing location before pushing new locations, as I want to carry over existing query parameters. To accomplish this, I have to manually listen for location changes:
const [history, setHistory] = useState<History | null>(null);
const [location, setLocation] = useState<Location | null>(null);
useEffect(() => {
view.createHistory().then((history) => {
history.listen((location) => {
setLocation(location);
console.log("location changed:", location); // this updates as expected
console.log("history.location:", history.location); // this never changes
});
setHistory(history);
setLocation(history.location);
});
}, []);
Am I missing something, or is this a bug in the framework? (I’m using @forge/bridge
v2.0.0, currently the latest.)