File tree Expand file tree Collapse file tree 3 files changed +8
-8
lines changed Expand file tree Collapse file tree 3 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ describe('unit test for linkFiber', () => {
47
47
} ) ;
48
48
49
49
test ( 'linkFiber should modify the setState of the stateful component' , ( ) => {
50
- expect ( snapShot . tree . children [ 0 ] . component . setState . name ) . toBe ( 'newSetState' ) ;
50
+ expect ( snapShot . tree . children [ 0 ] . component . setState . linkFiberChanged ) . toBe ( true ) ;
51
51
} ) ;
52
52
53
53
// test('newSetState should still setState correctly', () => {
Original file line number Diff line number Diff line change @@ -17,12 +17,14 @@ module.exports = (snap, mode) => {
17
17
18
18
function changeSetState ( component ) {
19
19
// check that setState hasn't been changed yet
20
- if ( component . setState . name === 'newSetState' ) return ;
20
+ if ( component . setState . linkFiberChanged ) return ;
21
21
22
22
// make a copy of setState
23
23
const oldSetState = component . setState . bind ( component ) ;
24
24
25
- function newSetState ( state , callback = ( ) => { } ) {
25
+ // replace component's setState so developer doesn't change syntax
26
+ // component.setState = newSetState.bind(component);
27
+ component . setState = ( state , callback = ( ) => { } ) => {
26
28
// dont do anything if state is locked
27
29
// UNLESS we are currently jumping through time
28
30
if ( mode . locked && ! mode . jumping ) return ;
@@ -32,10 +34,8 @@ module.exports = (snap, mode) => {
32
34
sendSnapshot ( ) ;
33
35
callback ( ) ;
34
36
} ) ;
35
- }
36
-
37
- // replace component's setState so developer doesn't change syntax
38
- component . setState = newSetState ;
37
+ } ;
38
+ component . setState . linkFiberChanged = true ;
39
39
}
40
40
41
41
function createTree ( currentFiber , tree = new Tree ( 'root' ) ) {
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " react-time-travel" ,
3
- "version" : " 1.0.4 " ,
3
+ "version" : " 1.1.0 " ,
4
4
"description" : " A library that helps debug React by memorizing the state of components with every render." ,
5
5
"main" : " index.js" ,
6
6
"repository" : {
You can’t perform that action at this time.
0 commit comments