Skip to content

Commit

Permalink
Simplify keys logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Dec 9, 2024
1 parent 9f92c5e commit 39bc8c1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/data/src/components/use-select/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' +
Expand Down

0 comments on commit 39bc8c1

Please sign in to comment.