|
1 | | -import React, { useEffect, useState, useCallback, useMemo, useRef } from "react"; |
| 1 | +import React, { useCallback, useEffect, useMemo, useRef, useState } from "react"; |
2 | 2 | import { getIn, setIn } from "./utils"; |
3 | 3 | import equal from "react-fast-compare"; |
4 | 4 |
|
@@ -162,8 +162,14 @@ export function useCreateFormex<T extends object>({ |
162 | 162 | ); |
163 | 163 |
|
164 | 164 | const resetForm = useCallback((props?: FormexResetProps<T>) => { |
165 | | - const { submitCount: submitCountProp, values: valuesProp, errors: errorsProp, touched: touchedProp } = props ?? {}; |
| 165 | + const { |
| 166 | + submitCount: submitCountProp, |
| 167 | + values: valuesProp, |
| 168 | + errors: errorsProp, |
| 169 | + touched: touchedProp |
| 170 | + } = props ?? {}; |
166 | 171 | valuesRef.current = valuesProp ?? initialValuesRef.current; |
| 172 | + initialValuesRef.current = valuesProp ?? initialValuesRef.current; |
167 | 173 | setValuesInner(valuesProp ?? initialValuesRef.current); |
168 | 174 | setErrors(errorsProp ?? {}); |
169 | 175 | setTouchedState(touchedProp ?? {}); |
@@ -254,5 +260,11 @@ export function useCreateFormex<T extends object>({ |
254 | 260 | controllerRef.current = controller; |
255 | 261 | }, [controller]); |
256 | 262 |
|
| 263 | + // @ts-ignore |
| 264 | + console.log("initialValuesRef.current.name", initialValuesRef.current.name); |
| 265 | + // @ts-ignore |
| 266 | + console.log("values.name", values.name); |
| 267 | + console.log("dirty", dirty); |
| 268 | + |
257 | 269 | return controller; |
258 | 270 | } |
0 commit comments