Skip to content

Commit

Permalink
Merge pull request #525 from preactjs/bugfix-router-swapping
Browse files Browse the repository at this point in the history
[preact-iso] Bugfix for swapping suspended routes
  • Loading branch information
marvinhagemeister authored Apr 2, 2021
2 parents 19bb41c + da714fc commit 79a1c7f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/preact-iso/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ export function Router(props) {
} else commit();
}, [url]);

return [prevChildren.current, curChildren.current];
// Note: curChildren must render first in order to populate pending.current
return [curChildren.current, prevChildren.current];
}

function Committer({ pending, children }) {
Expand All @@ -144,7 +145,9 @@ function Committer({ pending, children }) {

Router.Provider = LocationProvider;

LocationProvider.ctx = createContext(/** @type {{ url: string, path: string, query: object, route }} */ ({}));
/** @typedef {{ url: string, path: string, query: object, route, wasPush: boolean }} RouteInfo */

LocationProvider.ctx = createContext(/** @type {RouteInfo} */ ({}));
const RouteContext = createContext({});

export const Route = props => h(props.component, props);
Expand Down

0 comments on commit 79a1c7f

Please sign in to comment.