Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onChangeEvent,
onBlurName,
onBlurEvent,
...rest
}: Props) => {
const isCheckbox = type === 'checkbox';
const isOnChange = mode === 'onChange';
const isOnBlur = mode === 'onBlur';
const defaultData = isCheckbox
? isUndefined(defaultChecked)
? false
: defaultChecked
: defaultValue;
const [inputValue, setInputValue] = React.useState(defaultData);
const valueRef = React.useRef(defaultData);
const methods = useFormContext() || {};
const setValue = setValueFromProp || methods.setValue;
const register = registerFromProp || methods.register;
const unregister = unregisterFromProp || methods.unregister;
const commonTask = (target: any) => {
const data = getValue(target, { isCheckbox });
setInputValue(data);
valueRef.current = data;
return data;
};
const eventWrapper = (event: EventFunction, eventName: string) => {
return async (...arg: any) => {
const data = commonTask(await event(arg));
setValue(
name,
function Test() {
const data = useFormContext();
return <input name="bill">;
}