@rainbow-oh/yee-c 0.4.2 → 0.4.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rainbow-oh/yee-c",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "yee basic components",
5
5
  "keywords": [
6
6
  "react",
@@ -494,6 +494,10 @@ export class FormStore {
494
494
  } else {
495
495
  this.store = { ...this.store, [normalizedName]: value };
496
496
  }
497
+ // When value is not undefined, notify watchers to trigger re-rendering of useWatch
498
+ if (value !== undefined) {
499
+ this.notifyWatchers(normalizedName);
500
+ }
497
501
  }
498
502
  }
499
503
  entity.onStoreChange?.();
@@ -27,10 +27,17 @@ function useWatch<T = any>(
27
27
  Array.isArray(namePath) ? namePath.join('.') : (namePath as string),
28
28
  );
29
29
 
30
- const unsubscribe = formInstance.subscribe(namePath, () => {
30
+ const update = () => {
31
31
  const newValue = getWatchedValue();
32
32
  setValue((prev) => (prev === newValue ? prev : newValue));
33
- });
33
+ };
34
+
35
+ const unsubscribe = formInstance.subscribe(namePath, update);
36
+ // Re-read immediately after subscribing: the parent's useWatch captured its
37
+ // initial snapshot before child Form.Field wrote its initialValue, and the
38
+ // subscription may not yet exist when that write happens. This covers the gap.
39
+ update();
40
+
34
41
  return unsubscribe;
35
42
  }, [formInstance, namePath]);
36
43
 
@@ -36,8 +36,6 @@ const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
36
36
  defaultValue,
37
37
  });
38
38
 
39
- console.log('mergedValue: ', mergedValue, value);
40
-
41
39
  useEffect(() => {
42
40
  const ele = componentRef.current;
43
41
  if (ele && autoSize) {
package/src/version.ts CHANGED
@@ -4,7 +4,7 @@ declare global {
4
4
  }
5
5
  }
6
6
 
7
- export const version = "0.4.2";
7
+ export const version = "0.4.3";
8
8
 
9
9
  if (typeof window !== 'undefined') {
10
10
  window.__yee_c_version__ = version;