File tree 4 files changed +34
-3
lines changed
4 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -1250,7 +1250,7 @@ window.ReactDOM["default"] = window.ReactDOM;
1250
1250
} , {
1251
1251
key : 'updateCurrentPage' ,
1252
1252
value : function updateCurrentPage ( nextPage ) {
1253
- if ( nextPage !== this . state . currentPage ) {
1253
+ if ( typeof nextPage !== 'undefined' && nextPage !== this . state . currentPage ) {
1254
1254
this . setState ( { currentPage : nextPage } ) ;
1255
1255
}
1256
1256
}
Original file line number Diff line number Diff line change @@ -281,7 +281,7 @@ var Table = (function (_React$Component) {
281
281
} , {
282
282
key : 'updateCurrentPage' ,
283
283
value : function updateCurrentPage ( nextPage ) {
284
- if ( nextPage !== this . state . currentPage ) {
284
+ if ( typeof nextPage !== 'undefined' && nextPage !== this . state . currentPage ) {
285
285
this . setState ( { currentPage : nextPage } ) ;
286
286
}
287
287
}
Original file line number Diff line number Diff line change @@ -240,7 +240,7 @@ export class Table extends React.Component {
240
240
}
241
241
242
242
updateCurrentPage ( nextPage ) {
243
- if ( nextPage !== this . state . currentPage ) {
243
+ if ( typeof ( nextPage ) !== 'undefined' && nextPage !== this . state . currentPage ) {
244
244
this . setState ( { currentPage : nextPage } ) ;
245
245
}
246
246
}
Original file line number Diff line number Diff line change @@ -2580,4 +2580,35 @@ describe('Reactable', function() {
2580
2580
} ) ;
2581
2581
} ) ;
2582
2582
} )
2583
+
2584
+ describe ( 'receive props with no currentPage' , ( ) => {
2585
+ let parent ;
2586
+
2587
+ before ( function ( ) {
2588
+ //create a wrapper component so we can update its state and trigger componentWillReceiveProps in the table
2589
+ var TestParent = React . createFactory ( React . createClass ( {
2590
+ render ( ) {
2591
+ return ( < Reactable . Table className = "table" id = "table" ref = "table" >
2592
+ < Reactable . Tr >
2593
+ < Reactable . Td column = "Name" >
2594
+ < b > Griffin Smith</ b >
2595
+ </ Reactable . Td >
2596
+ </ Reactable . Tr >
2597
+ </ Reactable . Table > ) ;
2598
+ }
2599
+ } ) ) ;
2600
+
2601
+ parent = ReactDOM . render ( TestParent ( ) , ReactableTestUtils . testNode ( ) ) ;
2602
+ } ) ;
2603
+
2604
+ after ( ReactableTestUtils . resetTestEnvironment ) ;
2605
+
2606
+ it ( 'keeps the same currentPage and does not set it to undefined' , function ( ) {
2607
+ const preUpdateCurrentPage = parent . refs . table . state . currentPage ;
2608
+ parent . setState ( { testState : "this state update will trigger componentWillReceiveProps in the Reactable.Table" } ) ;
2609
+ const postUpdateCurrentPage = parent . refs . table . state . currentPage ;
2610
+ expect ( postUpdateCurrentPage ) . to . not . eq ( undefined ) ;
2611
+ expect ( postUpdateCurrentPage ) . to . eq ( preUpdateCurrentPage ) ;
2612
+ } ) ;
2613
+ } ) ;
2583
2614
} ) ;
You can’t perform that action at this time.
0 commit comments