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 authored and ljharb committed Jan 4, 2018
1 parent ba82e1d commit 30b4556
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 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

0 comments on commit 30b4556

Please sign in to comment.