diff --git a/packages/data/src/components/use-select/index.js b/packages/data/src/components/use-select/index.js index d61379b0425d1..f2a3ab9826f78 100644 --- a/packages/data/src/components/use-select/index.js +++ b/packages/data/src/components/use-select/index.js @@ -20,13 +20,15 @@ import useAsyncMode from '../async-mode-provider/use-async-mode'; const renderQueue = createQueue(); function warnOnUnstableReference( a, b ) { - let keys = []; - if ( a.constructor === Object && b.constructor === Object ) { - keys = Object.keys( a ).filter( ( k ) => a[ k ] !== b[ k ] ); - } else if ( Array.isArray( a ) && Array.isArray( b ) ) { - keys = [ ...a.keys() ].filter( ( i ) => a[ i ] !== b[ i ] ); + if ( ! a && ! b ) { + return; } + const keys = + typeof a === 'object' && typeof b === 'object' + ? Object.keys( a ).filter( ( k ) => a[ k ] !== b[ k ] ) + : []; + // eslint-disable-next-line no-console console.warn( 'The `useSelect` hook returns different values when called with the same state and parameters.\n' +