@plasmicapp/react-web 0.2.358 → 0.2.360

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/dist/index.cjs.js CHANGED
@@ -2239,7 +2239,17 @@ function create$StateProxy($$state, leafHandlers) {
2239
2239
  (_b = (_a = leafHandlers(ensureStateCell(receiver, property, nextPath, nextNode))).set) === null || _b === void 0 ? void 0 : _b.call(_a, target, property, value, receiver);
2240
2240
  Reflect.set(target, property, value, receiver);
2241
2241
  if (nextSpec === null || nextSpec === void 0 ? void 0 : nextSpec.onChangeProp) {
2242
- (_d = (_c = $$state.env.$props)[nextSpec.onChangeProp]) === null || _d === void 0 ? void 0 : _d.call(_c, value);
2242
+ var pathKey = JSON.stringify(nextPath);
2243
+ var isInitOnChange = !$$state.initializedLeafPaths.has(pathKey);
2244
+ // We need to call the onChangeProp during initialization process so that the parent
2245
+ // state can be updated with the correct value. We will provide an addtionnal parameter
2246
+ // to the onChangeProp function to indicate that the call is made during initialization.
2247
+ (_d = (_c = $$state.env.$props)[nextSpec.onChangeProp]) === null || _d === void 0 ? void 0 : _d.call(_c, value, {
2248
+ _plasmic_state_init_: isInitOnChange,
2249
+ });
2250
+ if (isInitOnChange) {
2251
+ $$state.initializedLeafPaths.add(pathKey);
2252
+ }
2243
2253
  }
2244
2254
  }
2245
2255
  if (!nextNode) {
@@ -2364,6 +2374,7 @@ function useDollarState(specs) {
2364
2374
  specs: [],
2365
2375
  registrationsQueue: [],
2366
2376
  stateInitializationEnv: { stack: [], visited: new Set() },
2377
+ initializedLeafPaths: new Set(),
2367
2378
  };
2368
2379
  })()).current;
2369
2380
  $$state.env = envFieldsAreNonNill(env);