This repository was archived by the owner on Aug 3, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +26
-2
lines changed
Expand file tree Collapse file tree 4 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 11# Changelog
22
3+ ### v2.0.3 (2018/3/2)
4+
5+ ** Bug Fixes**
6+
7+ * Fixes a bug where the ` lazy ` prop was not always respected. Anytime that a new request key was generated,
8+ a request would be made.
9+
310### v2.0.2 (2018/2/21)
411
512** Bug Fixes**
Original file line number Diff line number Diff line change 11{
22 "name" : " react-request" ,
3- "version" : " 2.0.2 " ,
3+ "version" : " 2.0.3 " ,
44 "description" : " Declarative HTTP requests with React." ,
55 "main" : " lib/index.js" ,
66 "module" : " es/index.js" ,
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ export class Fetch extends React.Component {
109109 method : this . props . method . toUpperCase ( )
110110 } ) ;
111111
112- if ( currentRequestKey !== nextRequestKey ) {
112+ if ( currentRequestKey !== nextRequestKey && ! this . isLazy ( nextProps ) ) {
113113 this . fetchData ( nextProps ) ;
114114 }
115115 }
Original file line number Diff line number Diff line change @@ -1428,4 +1428,21 @@ describe('laziness', () => {
14281428 expect ( beforeFetchMock ) . toHaveBeenCalledTimes ( 1 ) ;
14291429 } ) ;
14301430 } ) ;
1431+
1432+ test ( 'it should be respected when the props change' , ( ) => {
1433+ fetchMock . get ( '/test/hangs/double-request2' , hangingPromise ( ) ) ;
1434+
1435+ const afterFetchMock = jest . fn ( ) ;
1436+
1437+ const wrapper = shallow (
1438+ < Fetch url = "/test/hangs" afterFetch = { afterFetchMock } lazy />
1439+ ) ;
1440+
1441+ wrapper . setProps ( {
1442+ url : '/test/hangs/double-request2'
1443+ } ) ;
1444+
1445+ expect ( fetchMock . calls ( '/test/hangs' ) . length ) . toBe ( 0 ) ;
1446+ expect ( fetchMock . calls ( '/test/hangs/double-request2' ) . length ) . toBe ( 0 ) ;
1447+ } ) ;
14311448} ) ;
You can’t perform that action at this time.
0 commit comments