Skip to content

Commit

Permalink
Add isNaN helper for IE11 (#3981)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewiggins committed Apr 22, 2023
1 parent 7adb147 commit 6cc8688
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions debug/src/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
getCurrentVNode,
getDisplayName
} from './component-stack';
import { assign } from './util';
import { assign, isNaN } from './util';

const isWeakMapSupported = typeof WeakMap == 'function';

Expand Down Expand Up @@ -367,7 +367,7 @@ export function initDebug() {
const hook = hooks[i];
if (hook._args) {
for (const arg of hook._args) {
if (Number.isNaN(arg)) {
if (isNaN(arg)) {
const componentName = getDisplayName(vnode);
throw new Error(
`Invalid argument passed to hook. Hooks should not be called with NaN in the dependency array. Hook index ${i} in component ${componentName} was called with NaN.`
Expand Down
4 changes: 4 additions & 0 deletions debug/src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ export function assign(obj, props) {
for (let i in props) obj[i] = props[i];
return /** @type {O & P} */ (obj);
}

export function isNaN(value) {
return value !== value;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
"benchmark": "npm run test:karma:bench -- no-single-run",
"lint": "run-s eslint",
"eslint": "eslint src test debug compat hooks test-utils",
"format": "prettier --write '**/*.{js,jsx,mjs,cjs,ts,tsx,yml,json,html,md,css,scss}'",
"format": "prettier --write \"**/*.{js,jsx,mjs,cjs,ts,tsx,yml,json,html,md,css,scss}\"",
"format:check": "prettier --check '**/*.{js,jsx,mjs,cjs,ts,tsx,yml,json,html,md,css,scss}'"
},
"eslintConfig": {
Expand Down

0 comments on commit 6cc8688

Please sign in to comment.