sends fields on mount within useFieldType

This commit is contained in:
James
2020-09-05 17:44:41 -04:00
parent d99788f6f7
commit 4616e7fa16
2 changed files with 5 additions and 5 deletions

View File

@@ -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,

View File

@@ -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;