Skip to content

Commit c9b3d81

Browse files
authored
Merge pull request #8 from oslabs-beta/rajeeb/fix-router
Support React Router with browser history state change
2 parents 30feca1 + 9e1031a commit c9b3d81

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

package/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ window.addEventListener('message', ({ data: { action, payload } }) => { //runs a
1313
switch (action) {
1414
case 'jumpToSnap':
1515
timeJump(payload);
16+
// Get the pathname from payload and add new entry to browser history
17+
// MORE: https://developer.mozilla.org/en-US/docs/Web/API/History/pushState
18+
if (payload.children[0].state && payload.children[0].state.location) {
19+
const route = payload.children[0].state.location.pathname;
20+
window.history.pushState(route);
21+
}
1622
break;
1723
case 'setLock':
1824
mode.locked = payload;

0 commit comments

Comments
 (0)