@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.js CHANGED
@@ -1515,8 +1515,11 @@ function RenderForm({
1515
1515
  var _options$formState;
1516
1516
  return (_options$formState = options == null ? void 0 : options.formState) != null ? _options$formState : createFormState(schemaInterface);
1517
1517
  });
1518
- const effects = [];
1519
- const state = formState.getControlState(data, form, options, cb => effects.push(cb));
1518
+ let effects = [];
1519
+ const runAsync = cb => {
1520
+ if (effects) effects.push(cb);else cb();
1521
+ };
1522
+ const state = formState.getControlState(data, form, options, runAsync);
1520
1523
  useEffect(() => {
1521
1524
  if (!(options != null && options.formState)) {
1522
1525
  return () => formState.cleanup();
@@ -1602,7 +1605,7 @@ function RenderForm({
1602
1605
  textClass: textClass,
1603
1606
  getChildState(child, parent) {
1604
1607
  var _ref3;
1605
- return formState.getControlState((_ref3 = parent != null ? parent : state.dataNode) != null ? _ref3 : data, child, childOptions, cb => effects.push(cb));
1608
+ return formState.getControlState((_ref3 = parent != null ? parent : state.dataNode) != null ? _ref3 : data, child, childOptions, runAsync);
1606
1609
  },
1607
1610
  runExpression: (scope, expr, returnResult) => {
1608
1611
  if (expr != null && expr.type) {
@@ -1611,7 +1614,7 @@ function RenderForm({
1611
1614
  dataNode: data,
1612
1615
  schemaInterface,
1613
1616
  returnResult,
1614
- runAsync: cb => effects.push(cb)
1617
+ runAsync
1615
1618
  });
1616
1619
  }
1617
1620
  }
@@ -1626,7 +1629,11 @@ function RenderForm({
1626
1629
  visibility
1627
1630
  }, renderedControl));
1628
1631
  useEffect(() => {
1629
- effects.forEach(cb => cb());
1632
+ if (effects) {
1633
+ const toRun = effects;
1634
+ effects = undefined;
1635
+ toRun.forEach(cb => cb());
1636
+ }
1630
1637
  }, [effects]);
1631
1638
  return rendered;
1632
1639
  } finally {