Skip to content

Commit

Permalink
fix: preserve field state when $reserveOnUnmount
Browse files Browse the repository at this point in the history
  • Loading branch information
qiqiboy committed Sep 5, 2023
1 parent b45428f commit d531c1b
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 58 deletions.
28 changes: 14 additions & 14 deletions dist/react-formutil.cjs.development.js
Original file line number Diff line number Diff line change
Expand Up @@ -710,20 +710,20 @@ var Form = /*#__PURE__*/function (_Component) {
};
_this.$$unregister = function (name, $handler, $$reserved) {
if (name) {
if (name in _this.$$regDuplications) {
var _this$$$regDuplicatio = _slicedToArray(_this.$$regDuplications[name], 2),
$curRegistered = _this$$$regDuplicatio[0],
_$handler = _this$$$regDuplicatio[1];
_this.$$fieldChangedQueue.push({
name: name,
$newValue: _$handler.$getState().$value,
$prevValue: $curRegistered.$getState().$value
});
delete _this.$$regDuplications[name];
} else if (_this.$$registers[name] === $handler) {
if ($$reserved) {
$handler.$$reserved = true;
} else {
if ($$reserved) {
$handler.$$reserved = true;
} else {
if (name in _this.$$regDuplications) {
var _this$$$regDuplicatio = _slicedToArray(_this.$$regDuplications[name], 2),
$curRegistered = _this$$$regDuplicatio[0],
_$handler = _this$$$regDuplicatio[1];
_this.$$fieldChangedQueue.push({
name: name,
$newValue: _$handler.$getState().$value,
$prevValue: $curRegistered.$getState().$value
});
delete _this.$$regDuplications[name];
} else if (_this.$$registers[name] === $handler) {
delete _this.$$registers[name];
_this.$$fieldChangedQueue.push({
name: name,
Expand Down
2 changes: 1 addition & 1 deletion dist/react-formutil.cjs.production.js

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions dist/react-formutil.esm.development.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,20 +564,20 @@ var Form = /*#__PURE__*/function (_Component) {
};
_this.$$unregister = function (name, $handler, $$reserved) {
if (name) {
if (name in _this.$$regDuplications) {
var _this$$$regDuplicatio = _slicedToArray(_this.$$regDuplications[name], 2),
$curRegistered = _this$$$regDuplicatio[0],
_$handler = _this$$$regDuplicatio[1];
_this.$$fieldChangedQueue.push({
name: name,
$newValue: _$handler.$getState().$value,
$prevValue: $curRegistered.$getState().$value
});
delete _this.$$regDuplications[name];
} else if (_this.$$registers[name] === $handler) {
if ($$reserved) {
$handler.$$reserved = true;
} else {
if ($$reserved) {
$handler.$$reserved = true;
} else {
if (name in _this.$$regDuplications) {
var _this$$$regDuplicatio = _slicedToArray(_this.$$regDuplications[name], 2),
$curRegistered = _this$$$regDuplicatio[0],
_$handler = _this$$$regDuplicatio[1];
_this.$$fieldChangedQueue.push({
name: name,
$newValue: _$handler.$getState().$value,
$prevValue: $curRegistered.$getState().$value
});
delete _this.$$regDuplications[name];
} else if (_this.$$registers[name] === $handler) {
delete _this.$$registers[name];
_this.$$fieldChangedQueue.push({
name: name,
Expand Down
2 changes: 1 addition & 1 deletion dist/react-formutil.esm.production.js

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions dist/react-formutil.umd.development.js
Original file line number Diff line number Diff line change
Expand Up @@ -1003,20 +1003,20 @@
};
_this.$$unregister = function (name, $handler, $$reserved) {
if (name) {
if (name in _this.$$regDuplications) {
var _this$$$regDuplicatio = _slicedToArray(_this.$$regDuplications[name], 2),
$curRegistered = _this$$$regDuplicatio[0],
_$handler = _this$$$regDuplicatio[1];
_this.$$fieldChangedQueue.push({
name: name,
$newValue: _$handler.$getState().$value,
$prevValue: $curRegistered.$getState().$value
});
delete _this.$$regDuplications[name];
} else if (_this.$$registers[name] === $handler) {
if ($$reserved) {
$handler.$$reserved = true;
} else {
if ($$reserved) {
$handler.$$reserved = true;
} else {
if (name in _this.$$regDuplications) {
var _this$$$regDuplicatio = _slicedToArray(_this.$$regDuplications[name], 2),
$curRegistered = _this$$$regDuplicatio[0],
_$handler = _this$$$regDuplicatio[1];
_this.$$fieldChangedQueue.push({
name: name,
$newValue: _$handler.$getState().$value,
$prevValue: $curRegistered.$getState().$value
});
delete _this.$$regDuplications[name];
} else if (_this.$$registers[name] === $handler) {
delete _this.$$registers[name];
_this.$$fieldChangedQueue.push({
name: name,
Expand Down
2 changes: 1 addition & 1 deletion dist/react-formutil.umd.production.js

Large diffs are not rendered by default.

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": "1.1.8",
"version": "1.1.9",
"description": "Happy to build the forms in React ^_^",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
Expand Down
24 changes: 12 additions & 12 deletions src/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,20 @@ class Form extends Component {

$$unregister = (name, $handler, $$reserved) => {
if (name) {
if (name in this.$$regDuplications) {
const [$curRegistered, $handler] = this.$$regDuplications[name];
if ($$reserved) {
$handler.$$reserved = true;
} else {
if (name in this.$$regDuplications) {
const [$curRegistered, $handler] = this.$$regDuplications[name];

this.$$fieldChangedQueue.push({
name,
$newValue: $handler.$getState().$value,
$prevValue: $curRegistered.$getState().$value
});
this.$$fieldChangedQueue.push({
name,
$newValue: $handler.$getState().$value,
$prevValue: $curRegistered.$getState().$value
});

delete this.$$regDuplications[name];
} else if (this.$$registers[name] === $handler) {
if ($$reserved) {
$handler.$$reserved = true;
} else {
delete this.$$regDuplications[name];
} else if (this.$$registers[name] === $handler) {
delete this.$$registers[name];

this.$$fieldChangedQueue.push({
Expand Down

0 comments on commit d531c1b

Please sign in to comment.