Skip to content

Commit

Permalink
Add comments for an argument of setState callback
Browse files Browse the repository at this point in the history
  • Loading branch information
koba04 committed Jan 4, 2018
1 parent d3c6cf1 commit 40540e4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
} from 'enzyme-adapter-utils';

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

function compositeTypeToNodeType(type) {
switch (type) {
Expand Down Expand Up @@ -257,7 +256,8 @@ class ReactFifteenFourAdapter extends EnzymeAdapter {
}

invokeSetStateCallback(instance, callback) {
if (CALLING_SETSTATE_CALLBACK_WITH_UNDEFINED) {
// React in <= 15.3, and >= 16 pass undefined to a setState callback
if (MINOR_VERSION >= 4) {
callback.call(instance, undefined);
} else {
callback.call(instance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ class ReactFifteenAdapter extends EnzymeAdapter {
}

invokeSetStateCallback(instance, callback) {
// React in <= 15.3, and >= 16 pass undefined to a setState callback
callback.call(instance, undefined);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/enzyme-test-suite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.5.1"
}
}
}

0 comments on commit 40540e4

Please sign in to comment.