@@ -12,12 +12,9 @@ This method will watch specified inputs and return their values. It is useful to
1212
1313This function mainly serves ** two purposes** :
1414
15- 1 .  Returns and keep sync with fields' values
16-    a. <TypeText >` watch(name: string, defaultValue?): unknown ` </TypeText >
17-    b. <TypeText >` watch(names: string[], defaultValue?): {[key:string]: unknown} ` </TypeText >
18-    c. <TypeText >` watch(): {[key:string]: unknown} ` </TypeText >
19- 2 .  Start subscribing with given callback function (can be stopped by calling ` unsubscribe `  function)
20-    a. <TypeText >` watch(callback: (data, { name, type }) => void, defaultValues?): { unsubscribe: () => void } ` </TypeText >
15+ -  <TypeText >` watch(name: string, defaultValue?): unknown ` </TypeText >
16+ -  <TypeText >` watch(names: string[], defaultValue?): {[key:string]: unknown} ` </TypeText >
17+ -  <TypeText >` watch(): {[key:string]: unknown} ` </TypeText >
2118
2219The explanation of each of these four overloads follows below.
2320
@@ -73,7 +70,7 @@ Watch and subscribe to the entire form update/change based on onChange and re-re
7370const   formValues =  watch ()
7471``` 
7572
76- #### 2. Start watching  with callback fn <TypeText >` watch(callback: (data, { name, type }) => void, defaultValues?: {[key:string]: unknown}): { unsubscribe: () => void } ` </TypeText >  
73+ #### 2. < b >Deprecated:</ b > consider use or migrate to  [ subscribe ] ( /docs/useform/subscribe ) . Watching  with callback fn <TypeText >` watch(callback: (data, { name, type }) => void, defaultValues?: {[key:string]: unknown}): { unsubscribe: () => void } ` </TypeText >  
7774
7875--- 
7976
@@ -88,15 +85,6 @@ Subscribe to field update/change without trigger re-render.
8885
8986** Returns**  object with ` unsubscribe `  function.
9087
91- ``` tsx 
92- useEffect (() =>  {
93-   const   { unsubscribe } =  watch ((value ) =>  {
94-     console .log (value )
95-   })
96-   return  () =>  unsubscribe ()
97- }, [watch ])
98- ``` 
99- 
10088### Rules  
10189
10290--- 
@@ -134,14 +122,6 @@ function App() {
134122  const   watchAllFields =  watch () //  when pass nothing as argument, you are watching everything
135123  const   watchFields =  watch ([" showAge"  , " age"  ]) //  you can also target specific fields by their names
136124
137-   //  Callback version of watch.  It's your responsibility to unsubscribe when done.
138-   React .useEffect (() =>  {
139-     const   subscription =  watch ((value , { name , type  }) => 
140-       console .log (value , name , type )
141-     )
142-     return  () =>  subscription .unsubscribe ()
143-   }, [watch ])
144- 
145125  const   onSubmit =  (data :  IFormInputs ) =>  console .log (data )
146126
147127  return  (
@@ -174,14 +154,6 @@ function App() {
174154  const  watchAllFields  =  watch () //  when pass nothing as argument, you are watching everything
175155  const  watchFields  =  watch ([" showAge"  , " number"  ]) //  you can also target specific fields by their names
176156
177-   //  Callback version of watch.  It's your responsibility to unsubscribe when done.
178-   React .useEffect (() =>  {
179-     const  subscription  =  watch ((value , { name, type }) => 
180-       console .log (value, name, type)
181-     )
182-     return  () =>  subscription .unsubscribe ()
183-   }, [watch])
184- 
185157  const  onSubmit  =  (data ) =>  console .log (data)
186158
187159  return  (
0 commit comments