@@ -13,12 +13,6 @@ import useLiveRef from './useLiveRef';
1313type UseOnyxSelector < TKey extends OnyxKey , TReturnValue = OnyxValue < TKey > > = ( data : OnyxValue < TKey > | undefined ) => TReturnValue ;
1414
1515type UseOnyxOptions < TKey extends OnyxKey , TReturnValue > = {
16- /**
17- * If set to `false`, then no data will be prefilled into the component.
18- * @deprecated This param is going to be removed soon. Use RAM-only keys instead.
19- */
20- initWithStoredValues ?: boolean ;
21-
2216 /**
2317 * If set to `false`, the connection won't be reused between other subscribers that are listening to the same Onyx key
2418 * with the same connect configurations.
@@ -97,11 +91,10 @@ function useOnyx<TKey extends OnyxKey, TReturnValue = OnyxValue<TKey>>(
9791
9892 // Stores the previously result returned by the hook, containing the data from cache and the fetch status.
9993 // We initialize it to `undefined` and `loading` fetch status to simulate the initial result when the hook is loading from the cache.
100- // However, if `initWithStoredValues` is `false` we set the fetch status to `loaded` since we want to signal that data is ready.
10194 const resultRef = useRef < UseOnyxResult < TReturnValue > > ( [
10295 undefined ,
10396 {
104- status : options ?. initWithStoredValues === false ? 'loaded' : 'loading' ,
97+ status : 'loading' ,
10598 } ,
10699 ] ) ;
107100
@@ -133,9 +126,8 @@ function useOnyx<TKey extends OnyxKey, TReturnValue = OnyxValue<TKey>>(
133126 ( ) =>
134127 onyxSnapshotCache . registerConsumer ( {
135128 selector : options ?. selector ,
136- initWithStoredValues : options ?. initWithStoredValues ,
137129 } ) ,
138- [ options ?. selector , options ?. initWithStoredValues ] ,
130+ [ options ?. selector ] ,
139131 ) ;
140132
141133 useEffect ( ( ) => ( ) => onyxSnapshotCache . deregisterConsumer ( key , cacheKey ) , [ key , cacheKey ] ) ;
@@ -174,26 +166,16 @@ function useOnyx<TKey extends OnyxKey, TReturnValue = OnyxValue<TKey>>(
174166
175167 const getSnapshot = useCallback ( ( ) => {
176168 // Check if we have any cache for this Onyx key
177- // Don't use cache for first connection with initWithStoredValues: false
178- // Also don't use cache during active data updates (when shouldGetCachedValueRef is true)
169+ // Don't use cache during active data updates (when shouldGetCachedValueRef is true)
179170 const isFirstConnection = connectedKeyRef . current !== key ;
180- if ( ! ( isFirstConnection && options ?. initWithStoredValues === false ) && ! shouldGetCachedValueRef . current ) {
171+ if ( ! shouldGetCachedValueRef . current ) {
181172 const cachedResult = onyxSnapshotCache . getCachedResult < UseOnyxResult < TReturnValue > > ( key , cacheKey ) ;
182173 if ( cachedResult !== undefined ) {
183174 resultRef . current = cachedResult ;
184175 return cachedResult ;
185176 }
186177 }
187178
188- // We return the initial result right away during the first connection if `initWithStoredValues` is set to `false`.
189- if ( isFirstConnection && options ?. initWithStoredValues === false ) {
190- const result = resultRef . current ;
191-
192- // Store result in snapshot cache
193- onyxSnapshotCache . setCachedResult < UseOnyxResult < TReturnValue > > ( key , cacheKey , result ) ;
194- return result ;
195- }
196-
197179 // We get the value from cache while the first connection to Onyx is being made or if the key has changed,
198180 // so we can return any cached value right away. For the case where the key has changed, If we don't return the cached value right away, then the UI will show the incorrect (previous) value for a brief period which looks like a UI glitch to the user. After the connection is made, we only
199181 // update `newValueRef` when `Onyx.connect()` callback is fired.
@@ -255,7 +237,7 @@ function useOnyx<TKey extends OnyxKey, TReturnValue = OnyxValue<TKey>>(
255237 }
256238
257239 return resultRef . current ;
258- } , [ options ?. initWithStoredValues , key , memoizedSelector , cacheKey ] ) ;
240+ } , [ key , memoizedSelector , cacheKey ] ) ;
259241
260242 const subscribe = useCallback (
261243 ( onStoreChange : ( ) => void ) => {
@@ -266,7 +248,7 @@ function useOnyx<TKey extends OnyxKey, TReturnValue = OnyxValue<TKey>>(
266248 previousValueRef . current = null ;
267249 newValueRef . current = null ;
268250 sourceValueRef . current = undefined ;
269- resultRef . current = [ undefined , { status : options ?. initWithStoredValues === false ? 'loaded' : 'loading' } ] ;
251+ resultRef . current = [ undefined , { status : 'loading' } ] ;
270252 }
271253 // Force a cache re-read on every (re)subscription so any side effects from
272254 // subscribeToKey (e.g. addNullishStorageKey for skippable collection member ids)
@@ -299,7 +281,6 @@ function useOnyx<TKey extends OnyxKey, TReturnValue = OnyxValue<TKey>>(
299281 // Finally, we signal that the store changed, making `getSnapshot()` be called again.
300282 onStoreChange ( ) ;
301283 } ,
302- initWithStoredValues : options ?. initWithStoredValues ,
303284 waitForCollectionCallback : OnyxKeys . isCollectionKey ( key ) as true ,
304285 reuseConnection : options ?. reuseConnection ,
305286 } ) ;
@@ -315,7 +296,7 @@ function useOnyx<TKey extends OnyxKey, TReturnValue = OnyxValue<TKey>>(
315296 onStoreChangeFnRef . current = null ;
316297 } ;
317298 } ,
318- [ key , options ?. initWithStoredValues , options ?. reuseConnection ] ,
299+ [ key , options ?. reuseConnection ] ,
319300 ) ;
320301
321302 const result = useSyncExternalStore < UseOnyxResult < TReturnValue > > ( subscribe , getSnapshot ) ;
0 commit comments