Skip to content

Commit 71f9bef

Browse files
committed
Use Object.is instead of the adhoc func
1 parent 1fc8b65 commit 71f9bef

File tree

2 files changed

+1
-13
lines changed

2 files changed

+1
-13
lines changed

compat/src/hooks.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useState, useLayoutEffect, useEffect } from 'preact/hooks';
2-
import { is } from './util';
32

43
/**
54
* This is taken from https://github.com/facebook/react/blob/main/packages/use-sync-external-store/src/useSyncExternalStoreShimClient.js#L84
@@ -47,7 +46,7 @@ function didSnapshotChange(inst) {
4746
const prevValue = inst._value;
4847
try {
4948
const nextValue = latestGetSnapshot();
50-
return !is(prevValue, nextValue);
49+
return !Object.is(prevValue, nextValue);
5150
} catch (error) {
5251
return true;
5352
}

compat/src/util.js

-11
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,3 @@ export function shallowDiffers(a, b) {
1111
for (let i in b) if (i !== '__source' && a[i] !== b[i]) return true;
1212
return false;
1313
}
14-
15-
/**
16-
* Check if two values are the same value
17-
* @param {*} x
18-
* @param {*} y
19-
* @returns {boolean}
20-
*/
21-
export function is(x, y) {
22-
// TODO: can we replace this with Object.is?
23-
return (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y);
24-
}

0 commit comments

Comments
 (0)