@@ -78,10 +78,13 @@ function useOnyx<TKey extends OnyxKey, TReturnValue = OnyxValue<TKey>>(
7878 const previousKey = usePrevious ( key ) ;
7979
8080 const currentDependenciesRef = useLiveRef ( dependencies ) ;
81+ const selector = options ?. selector ;
8182
8283 // Create memoized version of selector for performance
8384 const memoizedSelector = useMemo ( ( ) => {
84- if ( ! options ?. selector ) return null ;
85+ if ( ! selector ) {
86+ return null ;
87+ }
8588
8689 let lastInput : OnyxValue < TKey > | undefined ;
8790 let lastOutput : TReturnValue ;
@@ -95,8 +98,8 @@ function useOnyx<TKey extends OnyxKey, TReturnValue = OnyxValue<TKey>>(
9598 const dependenciesChanged = ! shallowEqual ( lastDependencies , currentDependencies ) ;
9699 if ( ! hasComputed || lastInput !== input || dependenciesChanged ) {
97100 // Only proceed if we have a valid selector
98- if ( options ?. selector ) {
99- const newOutput = options . selector ( input ) ;
101+ if ( selector ) {
102+ const newOutput = selector ( input ) ;
100103
101104 // Deep equality mode: only update if output actually changed
102105 if ( ! hasComputed || ! deepEqual ( lastOutput , newOutput ) || dependenciesChanged ) {
@@ -110,8 +113,7 @@ function useOnyx<TKey extends OnyxKey, TReturnValue = OnyxValue<TKey>>(
110113
111114 return lastOutput ;
112115 } ;
113- // eslint-disable-next-line react-hooks/exhaustive-deps -- we only need options?.selector, not the entire options object
114- } , [ currentDependenciesRef , options ?. selector ] ) ;
116+ } , [ currentDependenciesRef , selector ] ) ;
115117
116118 // Stores the previous cached value as it's necessary to compare with the new value in `getSnapshot()`.
117119 // We initialize it to `null` to simulate that we don't have any value from cache yet.
0 commit comments