Skip to content

Commit 784c966

Browse files
authored
Merge pull request #21 from matthieu-foucault/NaN_handling
NaN handling
2 parents 3a2c647 + dd32c34 commit 784c966

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/trackForMutations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function detectMutations(isImmutable, trackedProperty, obj, sameParentRef = fals
2525

2626
const sameRef = prevObj === obj;
2727

28-
if (sameParentRef && !sameRef) {
28+
if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
2929
return { wasMutated: true, path };
3030
}
3131

test/trackForMutations.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ describe('trackForMutations', () => {
226226
fn: (s) => {
227227
return {...s, foo: {}};
228228
}
229+
},
230+
'having a NaN in the state': {
231+
getState: () => ({ a:NaN, b: Number.NaN }),
232+
fn: (s) => s
229233
}
230234
};
231235

0 commit comments

Comments
 (0)