Skip to content

Commit 4afbef7

Browse files
committed
Add comments for an argument of setState callback
1 parent d3c6cf1 commit 4afbef7

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

packages/enzyme-adapter-react-15.4/src/ReactFifteenFourAdapter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
} from 'enzyme-adapter-utils';
1919

2020
const MINOR_VERSION = React.version.split('.')[1];
21-
const CALLING_SETSTATE_CALLBACK_WITH_UNDEFINED = MINOR_VERSION >= 4;
2221

2322
function compositeTypeToNodeType(type) {
2423
switch (type) {
@@ -257,7 +256,8 @@ class ReactFifteenFourAdapter extends EnzymeAdapter {
257256
}
258257

259258
invokeSetStateCallback(instance, callback) {
260-
if (CALLING_SETSTATE_CALLBACK_WITH_UNDEFINED) {
259+
// React in <= 15.3, and >= 16 pass undefined to a setState callback
260+
if (MINOR_VERSION >= 4) {
261261
callback.call(instance, undefined);
262262
} else {
263263
callback.call(instance);

packages/enzyme-adapter-react-15/src/ReactFifteenAdapter.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ class ReactFifteenAdapter extends EnzymeAdapter {
255255
}
256256

257257
invokeSetStateCallback(instance, callback) {
258+
// React in <= 15.3, and >= 16 pass undefined to a setState callback
258259
callback.call(instance, undefined);
259260
}
260261
}

0 commit comments

Comments
 (0)