Skip to content

Commit 79a1c7f

Browse files
Merge pull request #525 from preactjs/bugfix-router-swapping
[preact-iso] Bugfix for swapping suspended routes
2 parents 19bb41c + da714fc commit 79a1c7f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/preact-iso/router.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ export function Router(props) {
135135
} else commit();
136136
}, [url]);
137137

138-
return [prevChildren.current, curChildren.current];
138+
// Note: curChildren must render first in order to populate pending.current
139+
return [curChildren.current, prevChildren.current];
139140
}
140141

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

145146
Router.Provider = LocationProvider;
146147

147-
LocationProvider.ctx = createContext(/** @type {{ url: string, path: string, query: object, route }} */ ({}));
148+
/** @typedef {{ url: string, path: string, query: object, route, wasPush: boolean }} RouteInfo */
149+
150+
LocationProvider.ctx = createContext(/** @type {RouteInfo} */ ({}));
148151
const RouteContext = createContext({});
149152

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

0 commit comments

Comments
 (0)