File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,8 @@ export default function (mapOnyxToState) {
41
41
this . tempState = { } ;
42
42
43
43
this . state = {
44
- loading : true ,
44
+ // If there are no required keys for init then we can render the wrapped component immediately
45
+ loading : requiredKeysForInit . length > 0 ,
45
46
} ;
46
47
}
47
48
Original file line number Diff line number Diff line change @@ -156,6 +156,25 @@ describe('withOnyx', () => {
156
156
} ) ;
157
157
} ) ;
158
158
159
+ it ( 'should render the WrappedComponent if no keys are required for init' , ( ) => {
160
+ const INITIAL_VALUE = 'initial_value' ;
161
+ const TestComponentWithOnyx = withOnyx ( {
162
+ text : {
163
+ key : 'test' ,
164
+ initWithStoredValues : false ,
165
+ } ,
166
+ } ) ( ViewWithText ) ;
167
+ TestComponentWithOnyx . defaultProps = {
168
+ text : INITIAL_VALUE ,
169
+ } ;
170
+ Onyx . set ( 'test_key' , 'test_text' ) ;
171
+ return waitForPromisesToResolve ( )
172
+ . then ( ( ) => {
173
+ const { getByTestId} = render ( < TestComponentWithOnyx collectionID = "1" /> ) ;
174
+ expect ( getByTestId ( 'text-element' ) . props . children ) . toEqual ( INITIAL_VALUE ) ;
175
+ } ) ;
176
+ } ) ;
177
+
159
178
it ( 'should pass a prop from one connected component to another' , ( ) => {
160
179
const collectionItemID = 1 ;
161
180
const onRender = jest . fn ( ) ;
You can’t perform that action at this time.
0 commit comments