Comparing version
@@ -582,3 +582,4 @@ // src/internal/path.ts | ||
allKeys.forEach((key) => { | ||
if (!values.has(key) || !initialValues.has(key)) { | ||
var _a; | ||
if (!values.has(key) || !((_a = initialValues.get(key)) == null ? void 0 : _a.hasValue())) { | ||
return; | ||
@@ -588,2 +589,4 @@ } | ||
const control = getControlState(formRef, key); | ||
if (!control.hasValue()) | ||
return; | ||
const controlValue = control.getValue(); | ||
@@ -678,3 +681,3 @@ if (controlValue.touched) { | ||
// src/hooks/useControlStateless.ts | ||
import { useEffect } from "react"; | ||
import { useCallback, useEffect } from "react"; | ||
function useControlStateless(...args) { | ||
@@ -705,3 +708,6 @@ const [formRef, keySelector, options = {}] = useHookParams(args); | ||
setValue: (value) => getMapValue(key, formRef.values).setValue(value), | ||
subscribe: (cb) => getMapValue(key, formRef.values).subscribe(cb), | ||
subscribe: useCallback( | ||
(cb) => getMapValue(key, formRef.values).subscribe(cb), | ||
[formRef] | ||
), | ||
touch: () => { | ||
@@ -734,3 +740,3 @@ const state$ = getControlState(formRef, key); | ||
); | ||
useEffect2(() => subscribe(setState), []); | ||
useEffect2(() => subscribe(setState), [subscribe]); | ||
return { | ||
@@ -737,0 +743,0 @@ ...control, |
@@ -638,3 +638,4 @@ "use strict"; | ||
allKeys.forEach((key) => { | ||
if (!values.has(key) || !initialValues.has(key)) { | ||
var _a; | ||
if (!values.has(key) || !((_a = initialValues.get(key)) == null ? void 0 : _a.hasValue())) { | ||
return; | ||
@@ -644,2 +645,4 @@ } | ||
const control = getControlState(formRef, key); | ||
if (!control.hasValue()) | ||
return; | ||
const controlValue = control.getValue(); | ||
@@ -760,3 +763,6 @@ if (controlValue.touched) { | ||
setValue: (value) => getMapValue(key, formRef.values).setValue(value), | ||
subscribe: (cb) => getMapValue(key, formRef.values).subscribe(cb), | ||
subscribe: (0, import_react2.useCallback)( | ||
(cb) => getMapValue(key, formRef.values).subscribe(cb), | ||
[formRef] | ||
), | ||
touch: () => { | ||
@@ -789,3 +795,3 @@ const state$ = getControlState(formRef, key); | ||
); | ||
(0, import_react3.useEffect)(() => subscribe(setState), []); | ||
(0, import_react3.useEffect)(() => subscribe(setState), [subscribe]); | ||
return { | ||
@@ -792,0 +798,0 @@ ...control, |
{ | ||
"version": "0.3.0-beta.11", | ||
"version": "0.3.0-beta.12", | ||
"license": "MIT", | ||
@@ -4,0 +4,0 @@ "main": "dist/index.js", |
96264
0.34%2392
0.5%