Socket
Socket
Sign inDemoInstall

react-hook-form

Package Overview
Dependencies
Maintainers
1
Versions
1030
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-hook-form - npm Package Compare versions

Comparing version 0.1.11 to 0.2.0-beta.1

4

dist/index.d.ts

@@ -26,3 +26,3 @@ declare type Validate = (data: string | number) => boolean;

minLength?: number;
eventAttached?: boolean;
eventAttached?: Array<string>;
watch?: boolean;

@@ -32,3 +32,3 @@ mutationWatcher?: any;

ref: any;
eventAttached?: boolean;
eventAttached?: Array<string>;
mutationWatcher?: any;

@@ -35,0 +35,0 @@ }>;

@@ -185,15 +185,17 @@ import { useRef, useState, useEffect } from 'react';

const isRadio = isRadioInput(type);
const event = isOnChange ? (isRadio ? 'change' : 'input') : 'blur';
if (isRadio) {
const options = field.options;
const attachedEvents = options[radioOptionIndex].eventAttached;
if (!options[radioOptionIndex])
return;
if (!options[radioOptionIndex].eventAttached) {
options[radioOptionIndex].ref.addEventListener(isOnChange ? 'change' : 'blur', validateWithStateUpdate);
options[radioOptionIndex].eventAttached = true;
if (!attachedEvents || (attachedEvents && !attachedEvents.includes(event))) {
options[radioOptionIndex].ref.addEventListener(event, validateWithStateUpdate);
options[radioOptionIndex].eventAttached = [...attachedEvents, event];
}
}
else {
if (!field.eventAttached) {
ref.addEventListener(isOnChange ? 'input' : 'blur', validateWithStateUpdate);
field.eventAttached = true;
if (!field.eventAttached || (field.eventAttached && !field.eventAttached.includes(event))) {
ref.addEventListener(event, validateWithStateUpdate);
field.eventAttached = [...field.eventAttached, event];
}

@@ -303,16 +305,14 @@ }

}
if (!fields.current[name].eventAttached) {
if (isRadioInput(type) && Array.isArray(options)) {
options.forEach(option => {
if (option.eventAttached)
return;
option.ref.addEventListener('change', validateWithStateUpdate);
option.eventAttached = true;
});
}
else {
ref.addEventListener('input', validateWithStateUpdate);
data.eventAttached = true;
}
if (isRadioInput(type) && Array.isArray(options)) {
options.forEach(option => {
if (option.eventAttached && option.eventAttached.includes('change'))
return;
option.ref.addEventListener('change', validateWithStateUpdate);
option.eventAttached = [...option.eventAttached, 'change'];
});
}
else if (fields.current[name].eventAttached && !fields.current[name].eventAttached.includes('input')) {
ref.addEventListener('input', validateWithStateUpdate);
data.eventAttached = [...data.eventAttached, 'input'];
}
previous.localErrors = Object.assign({}, previous.localErrors, fieldError);

@@ -319,0 +319,0 @@ return previous;

@@ -187,15 +187,17 @@ 'use strict';

const isRadio = isRadioInput(type);
const event = isOnChange ? (isRadio ? 'change' : 'input') : 'blur';
if (isRadio) {
const options = field.options;
const attachedEvents = options[radioOptionIndex].eventAttached;
if (!options[radioOptionIndex])
return;
if (!options[radioOptionIndex].eventAttached) {
options[radioOptionIndex].ref.addEventListener(isOnChange ? 'change' : 'blur', validateWithStateUpdate);
options[radioOptionIndex].eventAttached = true;
if (!attachedEvents || (attachedEvents && !attachedEvents.includes(event))) {
options[radioOptionIndex].ref.addEventListener(event, validateWithStateUpdate);
options[radioOptionIndex].eventAttached = [...attachedEvents, event];
}
}
else {
if (!field.eventAttached) {
ref.addEventListener(isOnChange ? 'input' : 'blur', validateWithStateUpdate);
field.eventAttached = true;
if (!field.eventAttached || (field.eventAttached && !field.eventAttached.includes(event))) {
ref.addEventListener(event, validateWithStateUpdate);
field.eventAttached = [...field.eventAttached, event];
}

@@ -305,16 +307,14 @@ }

}
if (!fields.current[name].eventAttached) {
if (isRadioInput(type) && Array.isArray(options)) {
options.forEach(option => {
if (option.eventAttached)
return;
option.ref.addEventListener('change', validateWithStateUpdate);
option.eventAttached = true;
});
}
else {
ref.addEventListener('input', validateWithStateUpdate);
data.eventAttached = true;
}
if (isRadioInput(type) && Array.isArray(options)) {
options.forEach(option => {
if (option.eventAttached && option.eventAttached.includes('change'))
return;
option.ref.addEventListener('change', validateWithStateUpdate);
option.eventAttached = [...option.eventAttached, 'change'];
});
}
else if (fields.current[name].eventAttached && !fields.current[name].eventAttached.includes('input')) {
ref.addEventListener('input', validateWithStateUpdate);
data.eventAttached = [...data.eventAttached, 'input'];
}
previous.localErrors = Object.assign({}, previous.localErrors, fieldError);

@@ -321,0 +321,0 @@ return previous;

{
"name": "react-hook-form",
"version": "0.1.11",
"version": "0.2.0-beta.1",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "module": "dist/index.es.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc