sends fields on mount within useFieldType
This commit is contained in:
@@ -31,6 +31,7 @@ const useFieldType = (options) => {
|
||||
|
||||
// Get field by path
|
||||
const field = getField(path);
|
||||
const fieldExists = Boolean(field);
|
||||
|
||||
const initialValue = field?.initialValue;
|
||||
|
||||
@@ -81,10 +82,10 @@ const useFieldType = (options) => {
|
||||
const valueToSend = enableDebouncedValue ? debouncedValue : internalValue;
|
||||
|
||||
useEffect(() => {
|
||||
if (valueToSend !== undefined) {
|
||||
if (valueToSend !== undefined || !fieldExists) {
|
||||
sendField(valueToSend);
|
||||
}
|
||||
}, [valueToSend, sendField]);
|
||||
}, [valueToSend, sendField, fieldExists]);
|
||||
|
||||
return {
|
||||
...options,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useEffect } from 'react';
|
||||
|
||||
const useUnmountEffect = callback => useEffect(() => {
|
||||
return callback;
|
||||
}, []);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
const useUnmountEffect = (callback) => useEffect(() => callback, []);
|
||||
|
||||
export default useUnmountEffect;
|
||||
|
||||
Reference in New Issue
Block a user