|
|
@ -5,6 +5,7 @@ import { |
|
|
|
forwardRef, |
|
|
|
forwardRef, |
|
|
|
ReactElement, |
|
|
|
ReactElement, |
|
|
|
useCallback, |
|
|
|
useCallback, |
|
|
|
|
|
|
|
useEffect, |
|
|
|
useImperativeHandle, |
|
|
|
useImperativeHandle, |
|
|
|
useMemo, |
|
|
|
useMemo, |
|
|
|
useState, |
|
|
|
useState, |
|
|
@ -166,6 +167,14 @@ const InputWithRef = forwardRef( |
|
|
|
[initOnFocus, inputTestBatch], |
|
|
|
[initOnFocus, inputTestBatch], |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Using any setState function synchronously in the render function |
|
|
|
|
|
|
|
* directly will trigger the 'cannot update a component while readering a |
|
|
|
|
|
|
|
* different component' warning. This can be solved by wrapping the |
|
|
|
|
|
|
|
* setState call(s) in a useEffect hook because it executes **after** the |
|
|
|
|
|
|
|
* render function completes. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
if (isFirstRender) { |
|
|
|
if (isFirstRender) { |
|
|
|
const isValid = |
|
|
|
const isValid = |
|
|
|
testInput?.call(null, { |
|
|
|
testInput?.call(null, { |
|
|
@ -175,6 +184,7 @@ const InputWithRef = forwardRef( |
|
|
|
|
|
|
|
|
|
|
|
onFirstRender?.call(null, { isValid }); |
|
|
|
onFirstRender?.call(null, { isValid }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}, [input.props.id, inputValue, isFirstRender, onFirstRender, testInput]); |
|
|
|
|
|
|
|
|
|
|
|
useImperativeHandle( |
|
|
|
useImperativeHandle( |
|
|
|
ref, |
|
|
|
ref, |
|
|
|