Skip to content

Commit 8bd3648

Browse files
committed
TimeJump now works with useState
1 parent 0b6e823 commit 8bd3648

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

package/linkFiber.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ module.exports = (snap, mode) => {
5252

5353
// redefining the dispatch function so we can inject our code
5454
component.queue.dispatch = function (fiber, queue, action) {
55+
console.log('mode', mode);
5556
if (mode.locked && !mode.jumping) return;
5657
oldDispatch(fiber, queue, action);
5758
setTimeout(() => {
@@ -104,7 +105,6 @@ module.exports = (snap, mode) => {
104105
memoizedState.traversed = traverseHooks(memoizedState);
105106
nextTree = tree.appendChild(memoizedState);
106107
}
107-
108108
// iterate through siblings
109109
createTree(sibling, tree);
110110
// iterate through children

package/timeJump.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,20 @@ module.exports = (origin, mode) => {
2323
});
2424
});
2525
}
26-
// else {
27-
// // if component uses hooks
28-
// // traverse down the memoize tree again
29-
// console.log('component', originNode.component);
30-
// originNode.component.queue.dispatch(target.state);
31-
// }
26+
else {
27+
// if component uses hooks
28+
// variable for current location
29+
let currLocation = originNode.component;
30+
// state no
31+
let stateNum = 1;
32+
console.log('component', originNode.component);
33+
// while loop through the memoize tree
34+
while (currLocation) {
35+
currLocation.queue.dispatch(target.state[`state${stateNum}`]);
36+
currLocation = currLocation.next;
37+
stateNum += 1;
38+
}
39+
}
3240
}
3341

3442
return target => {

0 commit comments

Comments
 (0)