Skip to content

Commit

Permalink
fix(FieldList): fix callback error
Browse files Browse the repository at this point in the history
  • Loading branch information
qiqiboy committed Apr 3, 2019
1 parent fe2a206 commit e10b9af
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
20 changes: 12 additions & 8 deletions lib/EasyField/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@ var EasyFieldList = (_temp = _class = function (_Component) {
};

_this.insert = function (m, callback) {
if (isUndefined(m)) {
callback = m;
if (isFunction(m)) {
var _ref3 = [callback, m];
m = _ref3[0];
callback = _ref3[1];
}

return _this.$setState(function (_ref3) {
var items = _ref3.items;
return _this.$setState(function (_ref4) {
var items = _ref4.items;

if (isUndefined(m)) {
items.push(_this.getId());
Expand All @@ -77,12 +79,14 @@ var EasyFieldList = (_temp = _class = function (_Component) {
};

_this.remove = function (m, callback) {
if (isUndefined(m)) {
callback = m;
if (isFunction(m)) {
var _ref5 = [callback, m];
m = _ref5[0];
callback = _ref5[1];
}

return _this.$setState(function (_ref4) {
var items = _ref4.items;
return _this.$setState(function (_ref6) {
var items = _ref6.items;

if (isUndefined(m)) {
items.pop();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-formutil",
"version": "0.5.6-beta.0",
"version": "0.5.6-beta.1",
"description": "Happy to build the forms in React ^_^",
"main": "lib/index.js",
"directories": {
Expand Down
8 changes: 4 additions & 4 deletions src/EasyField/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ class EasyFieldList extends Component {
}, callback);

insert = (m, callback) => {
if (isUndefined(m)) {
callback = m;
if (isFunction(m)) {
[m, callback] = [callback, m];
}

return this.$setState(({ items }) => {
Expand All @@ -88,8 +88,8 @@ class EasyFieldList extends Component {
};

remove = (m, callback) => {
if (isUndefined(m)) {
callback = m;
if (isFunction(m)) {
[m, callback] = [callback, m];
}

return this.$setState(({ items }) => {
Expand Down

0 comments on commit e10b9af

Please sign in to comment.