@react-typed-forms/schemas 16.0.2 → 16.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.cjs CHANGED
@@ -1613,9 +1613,10 @@ function RenderForm(_ref) {
1613
1613
  formState = _useState[0],
1614
1614
  setFormState = _useState[1];
1615
1615
  var effects = [];
1616
- var state = formState.getControlState(data, form, options, function (cb) {
1617
- return effects.push(cb);
1618
- });
1616
+ var runAsync = function runAsync(cb) {
1617
+ if (effects) effects.push(cb);else cb();
1618
+ };
1619
+ var state = formState.getControlState(data, form, options, runAsync);
1619
1620
  react.useEffect(function () {
1620
1621
  if (!(options != null && options.formState)) {
1621
1622
  return function () {
@@ -1702,9 +1703,7 @@ function RenderForm(_ref) {
1702
1703
  textClass: textClass,
1703
1704
  getChildState: function getChildState(child, parent) {
1704
1705
  var _ref4;
1705
- return formState.getControlState((_ref4 = parent != null ? parent : state.dataNode) != null ? _ref4 : data, child, childOptions, function (cb) {
1706
- return effects.push(cb);
1707
- });
1706
+ return formState.getControlState((_ref4 = parent != null ? parent : state.dataNode) != null ? _ref4 : data, child, childOptions, runAsync);
1708
1707
  },
1709
1708
  runExpression: function runExpression(scope, expr, returnResult) {
1710
1709
  if (expr != null && expr.type) {
@@ -1713,9 +1712,7 @@ function RenderForm(_ref) {
1713
1712
  dataNode: data,
1714
1713
  schemaInterface: schemaInterface,
1715
1714
  returnResult: returnResult,
1716
- runAsync: function runAsync(cb) {
1717
- return effects.push(cb);
1718
- }
1715
+ runAsync: runAsync
1719
1716
  });
1720
1717
  }
1721
1718
  }
@@ -1730,9 +1727,13 @@ function RenderForm(_ref) {
1730
1727
  visibility: visibility
1731
1728
  }, renderedControl));
1732
1729
  react.useEffect(function () {
1733
- effects.forEach(function (cb) {
1734
- return cb();
1735
- });
1730
+ if (effects) {
1731
+ var toRun = effects;
1732
+ effects = undefined;
1733
+ toRun.forEach(function (cb) {
1734
+ return cb();
1735
+ });
1736
+ }
1736
1737
  }, [effects]);
1737
1738
  return rendered;
1738
1739
  } finally {